自定义组件

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

自定义组件  使用 chooseImage  选择图片  使用Canvas 的

drawImage 图片显示不出来

不使用组件 正常绘制 ,使用组件绘制没有图片

<view>

<!-- 以下是对一个自定义组件的引用 –>

<my-component inner-text=“Some text”></my-component>

</view>

<view bindtap=“chooseimg”>上传图片</view>

<canvas canvas-id=‘mycavas’ style=“width:100%;height:300rpx;background:red;”></canvas>

js

chooseimg: function () {

wx.chooseImage({

success: function (res) {

console.log(“resresresresres”, res.tempFilePaths[0]);

ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 100)

ctx.draw()

},

})

}

1 回复
yongzhang
yongzhang1 楼4 年前

ctx在哪定义的?