新建一个小程序项目,
1、在pages/index.wxml中加入:
<canvas type='2d' id='testcanv' style='width:100%;height:300px'></canvas>
2、在app.js:onLoad中加入:
wx.createSelectorQuery().select('#testcanv').node((res)=>{
if (res && res.node) {
let {node:canvas}=res
console.log('found node!')
wx.getSystemInfo({success:sysinfo=>{
let s = "hello world"
let ctx = canvas.getContext('2d')
ctx.font = "32px bold Arial"
let w=ctx.measureText(s).width
ctx.fillText(s, sysinfo.screenWidth/2-w/2, 32)
}})
}
else console.log('node not found')
}).exec()
3、点击远程调试(测试机分别使用iPhoneXR 及 华为M6 pad, 系统及微信均更新到最新版), 开发工具抛出以下异常:
runtime.js?devtools_ignore=true:1 eval script evaluate_i #12 failed TypeError: r.Canvas is not a constructor
at n.value (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:733280)
at n.value (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:621289)
at t (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:621461)
at b (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:620332)
at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:732657)
at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:717590)
at Object.m (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:77498)
at Object.value [as subscribeHandler] (runtime.js?devtools_ignore=true:1)
at eval (eval at c (runtime.js?devtools_ignore=true:1), <anonymous>:1:17)
at eval (<anonymous>)
是的,我这边用canvas组件的页面,会闪退
微信升级至3.1.0.41,导致canvas报了这么一个错误。线上、预览模式闪退,真机调试调试报出了如上具体的错误,请问要怎么解决。
问题解决了吗?
楼主解决了没 这个垃圾小程序 真是各种坑 我也遇到这个 开发者工具正常运行,发布体验版,上线都是 闪退,真机调试的时候 就报 runtime.js?devtools_ignore=true:1 eval script evaluate_i #115 failed TypeError: r.Canvas is not a constructor 这个错误
请具体描述问题出现的流程,并提供能复现问题的简单代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html