[LayaAirIDE 2.0]2.0按钮添加事件报错 cannot read property 'on' fof undefined

class GameLogin extends ui.login.login_bgUI {
constructor() {
super();
this.btn_register.on("click", this, this.ToRegisterPage);
}
ToRegisterPage() : void {
this.loadScene("login/register_page");
}
}
 
//调用on的时候 直接会报Cannot read property 'on' of undefined
 
我再把生成的ui代码贴出来
export class login_bgUI extends View {
        public btn_close:Laya.Button;
        public lab_account:Laya.TextInput;
        public btn_login:Laya.Button;
        public lab_password:Laya.TextInput;
        public btn_register:Laya.Button;
        public chkbox_account_rem:Laya.CheckBox;
constructor(){ super()}
createChildren():void {
super.createChildren();
this.loadScene("login/login_bg");
}
}
已邀请:

182*****040

赞同来自:

我这个也出现同样的问题

赞同来自:

我也遇到了,请问楼主解决了吗

赞同来自:

同遇到这个问题,折腾好久了,麻烦官方回应一下这个问题怎么解决

qwer535305054

赞同来自:

我也遇到了,请问楼主解决了吗

1589358925用户

赞同来自:

这问题是真坑  我把UI.json文件的runtime 引用删了  重新引用  正常了

要回复问题请先

商务合作
商务合作