- 当前 Bug 的表现(可附上截图)
使用Canvas绘制二维码时,有部份Android用户反馈有时显示正常,有时不显示或显示一半,IOS不会有问题,本人的Android是小米6X也不会出现BUG。以下是我的代码
var QRErrorCorrectLevel = this.data.qrErrorCorrectLevel;
var options = this.data.options;
options.text = this.data.qrcodetxt;
var ctx = wx.createCanvasContext('firstCanvas')
var moduleCount = this.data.qrCodeData.moduleCount;
var tileW = options.width / moduleCount;
var tileH = options.height / moduleCount;
for (var row = 0; row < moduleCount; row++) {
for (var col = 0; col < moduleCount; col++) {
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileH) - Math.floor(row * tileH));
ctx.setFillStyle(this.data.qrCodeData.point[row][col])
ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);
}
}
ctx.draw();
- 预期表现
每一次都能正常绘制
- 复现路径
- 提供一个最简复现 Demo
我用
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
已经写明了!
var QRErrorCorrectLevel = this.data.qrErrorCorrectLevel;
var options = this.data.options;
options.text = this.data.qrcodetxt;
var ctx = wx.createCanvasContext('firstCanvas')
var moduleCount = this.data.qrCodeData.moduleCount;
var tileW = options.width / moduleCount;
var tileH = options.height / moduleCount;
for (var row = 0; row < moduleCount; row++) {
for (var col = 0; col < moduleCount; col++) {
var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW));
var h = (Math.ceil((row + 1) * tileH) - Math.floor(row * tileH));
ctx.setFillStyle(this.data.qrCodeData.point[row][col])
ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h);
}
}
ctx.draw();
代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)这个格式的