你想反馈一个 Bug 还是 提一个需求?
Bug
如果是 Bug:
* Bug 表现是什么?预期表现是什么?
iOS 真机中调试面板中报错
undefined is not an object (evaluating 'e.canvasId')
|
* 如何复现?
在 Component 中使用 canvas 绘图,移除组件后报错。
* 提供一个最简复现 Demo
Page({
data: {
show: true ,
},
handleToggle() {
this .setData({ show: ! this .data.show });
},
});
|
{
"navigationBarTitleText" : "canvasId error" ,
"usingComponents" : {
"custom-component" : "./custom-component/custom-component"
}
}
|
<!-- canvas-id-error.wxml -->
< block wx:if = "{{show}}" >
< custom-component ></ custom-component >
</ block >
< button bindtap = "handleToggle" >Toggle canvas</ button >
|
/* canvas-id-error.wxss */
custom-component {
width : 750 rpx;
height : 750 rpx;
display : block ;
}
|
Component({
attached() {
this .canvasContext = wx.createCanvasContext( 'my-canvas-id' , this );
this ._render();
},
detached() {
this .canvasContext = null ;
},
methods: {
_render() {
if (! this .canvasContext) {
return ;
}
const ctx = this .canvasContext;
ctx.moveTo(10, 10);
ctx.lineTo(100, 10);
ctx.lineTo(100, 100);
ctx.fill();
ctx.draw();
},
},
});
|
<!-- custom-component/custom-component.wxml -->
< canvas canvas-id = "my-canvas-id" ></ canvas >
|
/* custom-component/custom-component.wxss */
canvas {
width : 750 rpx;
height : 750 rpx;
display : block ;
}
|
麻烦给个相关的代码片段(https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/minicode.html),我们定位下问题
同样的问题,请问怎么解决的
请问这个怎么解决的,我也是报这个错
解决了吗,什么原因?
wechatide://minicode/QIA126mN6SYC