https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html
用官方上面文档的代码,
const query = wx.createSelectorQuery()
query.select('#myCanvas')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node
const ctx = canvas.getContext('2d')
const dpr = wx.getSystemInfoSync().pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
ctx.scale(dpr, dpr)
ctx.fillRect(0, 0, 100, 100)
})
ctx.fillRect(0, 0, 100, 100)填充一个矩形, 模拟器能看到这个矩形,但是手机上根本没有,真机调试也看不到,请问这是为什么?
核对下wxml 里canvas标签有没有写?方法是不是在onReady 生命周期里调用的?