Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'getChoosed' of undefined; #75

Open
litoxy opened this issue Jun 7, 2018 · 1 comment
Open

Cannot read property 'getChoosed' of undefined; #75

litoxy opened this issue Jun 7, 2018 · 1 comment

Comments

@litoxy
Copy link

litoxy commented Jun 7, 2018

default
` 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

@lq2391570
Copy link

同样出现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants