wx.createCanvasContext()停止维护,可以使用NodesRef.context替代
代码示例
<canvas id="ssd" canvas-id="myca"></canvas>
1、 wx.createCanvasContext (停止维护)
let canvasBox = null;
canvasBox = wx.createCanvasContext("myca");
2、替代写法NodesRef.context(function callback)
wx.createSelectorQuery().select('#myca').context(function (res) { console.log(res.context) // 节点对应的 Context 对象。如:选中的节点是 <video> 组件,那么此处即返回 VideoContext 对象 }).exec()
相关文档链接
createCanvasContext:https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html
createSelectorQuery:https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.context.html