新canvasAPI重复渲染,工具上没问题,真机预览和真机调试均出现bug?
onShow: function(){
this.initClock();
this.interval = setInterval(this.initClock, 40);
},
onUnload: function(){
clearInterval(this.interval)
},
initClock(){
const query = wx.createSelectorQuery()
query.select('#myClock')
.fields({ node: true, size: true })
.exec((res) => {
const canvas = res[0].node
const dpr = wx.getSystemInfoSync().pixelRatio
canvas.width = res[0].width * dpr
canvas.height = res[0].height * dpr
var ctx = canvas.getContext('2d')
ctx.scale(dpr, dpr)
this.drawClock(ctx)
})
},
就一个非常简单的重复渲染模拟一个时钟的方法,开发者工具上没问题,但是在真机上,不重复渲染