Cannot read property 'getChoosed' of undefined;
` for(var i=0;i<this.data.ctxData.length;i++)
{
this.imgs[i] = new Shape('image', { x: this.data.ctxData[i][0], y: this.data.ctxData[i][1],w:this.data.ctxwidth,h:this.data.ctxheight, file:"../../images/coin.png"}, 'fill', true);
this.text[i] = new Shape('text', { x: this.data.ctxData[i][0]-10, y: this.data.ctxData[i][1]+50, text:this.data.coins[i],fillStyle: "#000000"},'fill', true);
let img = this.imgs[i];
this.data.shapid[img.Shapeid] = i;
let text = this.text[i];
this.wxCanvas.add(img);
this.wxCanvas.add(text);
// console.log( img.destroy());
img.bind('tap',that.moveCtr);
img.animate("y", "+=10", { duration: 1000 },{ easing: "swingFrom", duration: 1000 }).animate("y", "-=10", { duration: 1000 },{ easing: "swingFrom", duration: 1000 }).start(true);
text.animate("y", "+=10", { duration: 1000 },{ easing: "swingFrom", duration: 1000 }).animate("y", "-=10", { duration: 1000 },{ easing: "swingFrom", duration: 1000 }).start(true);
}
moveCtr:function(e) {
var idx = this.data.shapid[e.Shapeid];
// this.imgs].destroy();
console.log( this.imgs[idx].destroy());
// this.imgs[idx].updateOption({file:"../../images/eye.png"});
// console.log( e.destroy());
//
// console.log(img._layerIndex);
//
// that.imgs2[i] = img.clone();
//
//
// img.updateOption({ fillStyle:"#ffffff"});
// that.wxCanvas.add(that.imgs2[i]);
// that.imgs2[i].animate({ "x": width/2, "y": height/2},
// { duration: 500 ,easing:"easeInQuad"}).start(1);
// setTimeout(function(){
// that.imgs2[i].destroy()
// },500)
},`
Hi,bobiscool
首先非常感谢这个组件。
我遇到的问题是,循环生成Shape对象。并绑定事件。当点击shape对象的时候 destroy() 当前对象。
但是,发现总会出现Cannot read property 'getChoosed' of undefined的错误:
thirdScriptError Cannot read property 'getChoosed' of undefined;at pages/orderconfirm/index page bindtap function TypeError: Cannot read property 'getChoosed' of undefined at WxDraw.getDetectedLayers (http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:4407:71) at http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:3624:35 at Array.forEach (<anonymous>) at http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:3620:32 at Array.forEach (<anonymous>) at eventBus.dispatch (http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:3617:24) at Shape.detect (http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:3839:22) at WxDraw.<anonymous> (http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:4307:18) at Array.forEach (<anonymous>) at WxDraw.tapDetect (http://127.0.0.1:50576/appservice/utils/wxdraw.min.js:4306:26)
烦请抽空debug下。Thx
同样出现