Canvas draw(reserve,callback) 回调只能调一次
发布于 5 年前 作者 xuyan 17357 次浏览 来自 问答

var ctx;

onLoad: function (options) {

   ctx = wx.createCanvasContext('myCanvas');

   this.Draw();

},


Draw: function () {

   debugger

 let colors = ["#6A0000", "#900000", "#902B2B", "#A63232", "#A62626", "#FD5039", "#C12F2A", "#FF6540", "#f93801"];

   let colornum = colors[~~(Math.random() * colors.length)];

   ctx.setFillStyle(colornum)

   ctx.fillRect(10, 10, 150, 100)

   ctx.draw(false, this.Draw);

},

这时Draw()方法调用2次后停止,请问这是啥问题?应该无限调用啊!

1 回复

麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

回到顶部