1

我将它与 angular (ngx-blockly) 一起使用,我想创建自定义块,如 moveforward 等,所以我按照教程ngx-blockly中的所有步骤操作,但我不断收到关于块类型的错误,我没有找到有关块类型的信息,创建自己的块时是否有特定类型,就像在本教程中一样,错误是关于“测试”

这是错误在此处输入图像描述 ,这是我的自定义块代码

 import { CustomBlock, NgxBlocklyComponent } from 'ngx-blockly';
 import { ViewChild } from '@angular/core';

 declare var Blockly: any;

 export class TestBlock extends CustomBlock {
 constructor() {
 super('TestBlock');
 this.class = TestBlock;
  }

defineBlock() {
this.block
  .appendDummyInput()
  .appendField(this.type)
this.block.setOutput(true, 'Input');
this.block.setColour(30);
this.block.setTooltip('');
this.block.setHelpUrl('');
}

toXML() {
return '<block type="test"></block>';
}
onChange(changeEvent: any) {
console.log(changeEvent);
}
 toDartCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

 toJavaScriptCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

 toLuaCode(block: CustomBlock): string | any[] {
 return 'Not implemented';
 }

toPHPCode(block: CustomBlock): string | any[] {
return 'Not implemented';
}

toPythonCode(block: CustomBlock): string | any[] {
return 'Not implemented';
}


 }
4

0 回答 0