let sharedCanvas = wx.getSharedCanvas();
let sharedContext = sharedCanvas.getContext(‘2d’)
let canvas = wx.createCanvas();
canvas.width = sharedCanvas.width;
canvas.height = sharedCanvas.height;
wx.onMessage(data => {
sharedContext.drawImage(canvas, 0, 0);
});
以上代码会报错,同样会报错的还有wx.createImage返回的对象一样会报错,这个刚才看到论坛里有一样的问题,到现在仍然没解决。
如果不在wx.onMessage理调用,比如直接在代码段里调用是没问题的,只要是在wx.xxxx的回调里执行都会报错,希望尽快解决这个问题。
------------------------------------------------------------------------------------------------------------------------------------------
gameSubContextThirdScriptError
Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The provided value is not of type ‘(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)’;at onMessage callback function
TypeError: Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The provided value is not of type ‘(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)’
at CanvasRenderingContext2D.t.(anonymous function) (http://127.0.0.1:57565/game/__dev__/WAGame.js:12:17613)
at CanvasRenderingContext2D.e.(anonymous function) [as drawImage] (http://127.0.0.1:57565/game/__dev__/WAGame.js:12:18953)
at Function.<anonymous> (http://127.0.0.1:57565/game/js/open/index.js:11:17)
at f.<anonymous> (http://127.0.0.1:57565/game/__subdev__/WAGameSubContext.js:4:26185)
at f.emit (http://127.0.0.1:57565/game/__subdev__/WAGameSubContext.js:4:453)
at http://127.0.0.1:57565/game/__subdev__/WAGameSubContext.js:4:8953
at Object.p [as subscribeHandler] (http://127.0.0.1:57565/game/__subdev__/WAGameSubContext.js:3:13572)
at http://127.0.0.1:57565/game/__dev__/WAGame.js:3:16001
at Array.forEach (<anonymous>)
at Object.S [as publish] (http://127.0.0.1:57565/game/__dev__/WAGame.js:3:15965)