收藏
回答

使用canvas 在真机调试时闪退?

 用canvas 画了个东西,真机调试的时候闪退

const query = wx.createSelectorQuery()

    query.select('#controlStripCanvas')

      .fields({ node: true, size: true })

      .exec((res) => {


        var width = 414*0.05 ,   height = 896*0.2;

        // wx.getSystemInfo({

        //   success: (result) => {

        //     height = result.screenHeight*0.2

        //     width = result.screenWidth*0.05

        //     console.log("result",result);

        //   },

        // })

     


        const canvas = res[0].node

        const ctx = canvas.getContext('2d')

       

       

        ctx.beginPath();

        ctx.arc(0.5*width,0.125*height,0.25*width,0, 1*Math.PI,true);

        ctx.arc(0.5*width,0.875*height,0.05*width,1*Math.PI, 2*Math.PI,true);

        ctx.closePath();

        ctx.stroke();

        ctx.fillStyle="#1B1727";

        ctx.fill();


        ctx.beginPath();

        ctx.arc(0.5*width,0.3*height,0.2*width,0, 1*Math.PI,true);

        ctx.arc(0.5*width,0.875*height,0.05*width,1*Math.PI, 2*Math.PI,true);

        ctx.closePath();

        ctx.stroke();

        ctx.fillStyle="#40F2F9";

        ctx.fill();


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签