[LayaAirIDE2]按钮事件 出错啦,请把此信息截图给研发商 Uncaught TypeError: Cannot read property 'on' of und

this.btnTest.on(Laya.Event.CLICK, this, () => {
            //点击后,打开3D混合场景示例
            Laya.Scene.open("d3Demo/D3Main.scene");
        }); 2D示例, 在IDE 加了个按钮 btnTest .在vscode 加上述事件,为什么 报错: 出错啦,请把此信息截图给研发商
Uncaught TypeError: Cannot read property 'on' of undefinedTypeError: Cannot read property 'on' ofundefinedat Index.onEnable (file:///E:/layademo/myLaya/bin/js/bundle.js:137:25)at Index. onEnable (file:///E:/layademo/myLaya/bin/libs/laya.core.js:23355:18)at Scene. activeScripts (file:///E:/layademo/myLaya/bin/libs/
已邀请:

layabox

赞同来自:

不是加了就能用,需要定义为变量。
另外,提问题,要给复现DEMO,不然只能是盲猜

要回复问题请先

商务合作
商务合作