我想批量自定义,但按照在线资源的说明进行操作后,我没有看到浏览器中出现任何内容。
这是示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blockly test</title>
<!-- core library -->
<script src="https://unpkg.com/blockly/blockly.min.js"></script>
</head>
<body>
<div id="editor"></div>
<xml id="toolbox">
<block type="controls_if"></block>
<block type="controls_repeat_ext"></block>
<block type="logic_compare"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
<script>
Blockly.Blocks['constant_value'] = {
init: function () {
this.appendValueInput('VALUE')
.setCheck('String')
.appendField('TEST');
this.setOutput(true, 'Number');
this.setColour(160);
this.setTooltip('Returns number of letters in the provided text.');
this.setHelpUrl('http://www.w3schools.com/jsref/jsref_length_string.asp');
}
}
var workspacePlayground = Blockly.inject('editor',
{ toolbox: document.getElementById('toolbox') });
</script>
</body>
</html>
如何让 Blockly 编辑器出现?