[LayaAir3]LayaIDE环境运行异步方法出现异常
这段异步加载代码运行异常,没有加载完就跳出异步往下执行了,就是日志3会比日志2先打印了,资源是正常的,会是什么原因?
do() {
let tex;
let f = async()=>{
console.log("1");
tex = await this.loadTexAsync(data);
console.log("3");
}
f();
}
async loadTexAsync(data: ArrayBuffer): Promise<Laya.Texture> {
return new Promise((resolve, reject)=>{
Laya.loader.load(url, Laya.Handler.create(this, (tex:any)=>{
if(!tex) reject(null);
console.log("2");
resolve(tex);
}), null, Laya.Loader.IMAGE);
});
}
do() {
let tex;
let f = async()=>{
console.log("1");
tex = await this.loadTexAsync(data);
console.log("3");
}
f();
}
async loadTexAsync(data: ArrayBuffer): Promise<Laya.Texture> {
return new Promise((resolve, reject)=>{
Laya.loader.load(url, Laya.Handler.create(this, (tex:any)=>{
if(!tex) reject(null);
console.log("2");
resolve(tex);
}), null, Laya.Loader.IMAGE);
});
}
没有找到相关结果
已邀请:
要回复问题请先登录
0 个回复