// src/myOpenDataContext/index.js let sharedCanvas = wx.getSharedCanvas(); let context = sharedCanvas.getContext( "2d" ); context.fillStyle = "#fff" ; context.fillRect(0, 0, 100, 100); context.fillText( "获取的数据" , 0, 0); |
//game.js let openDataContext = wx.getOpenDataContext(); let sharedCanvas = openDataContext.canvas; let canvas = wx.createCanvas(); let context = canvas.getContext( "2d" ); context.drawImage(sharedCanvas, 0, 0); // new Main(); |
我想让开放域上的离屏canvas在主域上显示,但是完全没效果,全部是黑色,这是为什么
有子域之后主域就不能再有新的canvas引入了,主域子域都只能围绕共享canvas来做,你在主域获取opendataContext.canvas之后把它塞给Texture赋值给主域的一个容器节点里面就能显示
解决了吗,同问