[英]Blockly repeat block not working with both custom block and predefined blocks
I'm working on an Angular project using Blockly and Phaser but repeat block is not working.我正在使用 Blockly 和 Phaser 开发一个 Angular 项目,但重复块不起作用。 Here is a small test to print
aa
3 times.这是打印
aa
3 次的小测试。
But I received this error:但是我收到了这个错误:
Here is the code used:这是使用的代码:
<block type="controls_repeat_ext">
<value name="TIMES">
<shadow type="math_number">
<field name="NUM">3</field>
</shadow>
</value>
</block>
//and for the function
run.on(event.POINTER_DOWN ,(image) => {
eval(document.getElementById('code').innerHTML);
console.log("running" )
});
What should I add to make this repeat work?我应该添加什么来使这个重复工作?
i just solved the problem by adding this code:我刚刚通过添加这段代码解决了这个问题:
(Blockly as any).JavaScript.addReservedWords('div2');
var code = (Blockly as any).JavaScript.workspaceToCode();
try {
eval(code);
} catch (e) {
alert(e);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.