自定义组件内使用canvas无反应

发布于 8 年前作者 ping809640 次浏览最后编辑 8 年前来自 ask

<canvas canvas-id=“myCanvas”></canvas>

/**

  * 组件的生命周期

  */

lifetimes: {

    created() {

        this.paint()

    }

},

methods: {

    paint() {

        const ctx = wx.createCanvasContext(‘myCanvas’)

        ctx.setFillStyle(“#EB0000”)

        ctx.setFontSize(10)

        ctx.fillText(‘¥’,10,84)

        ctx.draw()

    }

}

2 回复
jiexue
jiexue2 楼6 年前

 const ctx = wx.createCanvasContext(‘myCanvas’, this)