兄弟,你的问题解决了吗?我也遇到了,开启2d,红米机型偶尔有闪退。其他机型没出现。关闭2d就正常了
小程序有<canvas type="2d">,预览正常,调试闪退手机:Redmi K30i 5G <!--index.wxml--> <view class="container"> <text class="user-motto">{{motto}}</text> <canvas class="test-canvas" canvas-id="test-canvas" width="750" height="750"></canvas> <canvas class="test-canvas-2d" type="2d" width="750" height="750"></canvas> </view> /**index.wxss**/ .test-canvas { width:100vw; height:100vw; background:#f0f0f0; } .test-canvas-2d { width:100vw; height:100vw; background:#fff0f0; } //index.js //获取应用实例 const app = getApp() Page({ data: { motto: 'Hello World', }, testOldCanvas(){ const ctx=wx.createCanvasContext('test-canvas'); ctx.fillStyle='rgba(0,0,0,0.3)'; ctx.fillRect(10,10,350,350); ctx.drawImage('/images/earth.jpg',5,5,200,200); ctx.draw(); }, testNewCanvas(){ }, onReady: function () { this.testOldCanvas(); } }) https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html
2022-01-12