[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");
}
}
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");
}
}
没有找到相关结果
已邀请:
要回复问题请先登录
5 个回复
182*****040
赞同来自:
天
赞同来自:
喆
赞同来自:
qwer535305054
赞同来自:
1589358925用户
赞同来自: