开放数据域 绘制图片 刷新画布后[wxgl]invalid drawimage
获取图片部分 [代码]function[代码] [代码]preloadAvatar() {[代码][代码] [代码][代码]console.log([代码][代码]'preload avatar...'[代码][代码]);[代码][代码] [代码][代码]//如果超过1.5秒没有加载成功,使用默认头像 [代码][代码] [代码][代码]setTimeout(() => {[代码][代码] [代码][代码]if[代码] [代码](loadAvatarFail) {[代码][代码] [代码][代码]console.log([代码][代码]"头像加载失败"[代码][代码]);[代码][代码] [代码][代码]// createScene();[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]}, 1500);[代码][代码] [代码][代码]let preloaded = 0;[代码][代码] [代码][代码]let count = 0;[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i [代码][代码]in[代码] [代码]friendData) {[代码][代码] [代码][代码]count++;[代码][代码] [代码][代码]let img = wx.createImage();[代码][代码] [代码][代码]//处理没有头像的情况[代码][代码] [代码][代码]if[代码] [代码](friendData[i][[代码][代码]'avatar'[代码][代码]] == [代码][代码]""[代码][代码]) {[代码][代码] [代码][代码]friendData[i][[代码][代码]'avatar'[代码][代码]] = assets.avatar;[代码][代码] [代码][代码]preloaded++;[代码][代码] [代码][代码]}[代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]img.src = friendData[i][[代码][代码]'avatar'[代码][代码]];[代码][代码] [代码][代码]friendData[i][[代码][代码]'avatar'[代码][代码]] = img;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]img.onload = ()=> {[代码][代码] [代码][代码]preloaded++;[代码][代码] [代码][代码]if[代码] [代码](preloaded == count) {[代码][代码] [代码][代码]loadAvatarFail = [代码][代码]false[代码][代码];[代码][代码] [代码][代码]console.log([代码][代码]"头像加载完毕"[代码][代码]);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码]}[代码] 使用图片部分 [代码]context = sharedCanvas.getContext([代码][代码]"2d"[代码][代码]);[代码][代码] [代码][代码]context.globalCompositeOperation = [代码][代码]"source-over"[代码][代码];[代码][代码]context.drawImage(assets.panel,(stageWidth - assets.panel.width) / 2,(stageHeight - assets.panel.height) / 2)[代码][代码] [代码][代码]context.drawImage(assets.content,(stageWidth - assets.content.width) / 2,((stageHeight - assets.content.height) / 2 ) - 20)[代码] 模拟器的是可以跑 并且没有报错,但是真机显示第二真后 就没有图片了 [wxgl]invalid drawimage