<canvas id="canvas" canvas-id="canvas" style="width:100px;height:100px"></canvas>
var select = wx.createSelectorQuery() select.select('#canvas').context(res => { var ctx = res.context ctx.setFillStyle("#FF0000") ctx.fillRect(0, 0, 100, 100) ctx.draw() }).exec()
效果图:
关于Canvas详细使用方法:点击此处进入微信官方文档