- 当前 Bug 的表现(可附上截图)
开发工具和安卓端及ios9测试均正常,ios11测试导出图片路径失败,fail原因:canvasToTempFilePath: fail canvas is empty;试过在draw回调中使用canvasToTempFilePath,亦不能正常导出路径
-部分代码如下:
var context = wx.createCanvasContext(‘canvas’);
var path = “/images/img-share4.jpg”;
context.drawImage(path, 0, 0, 520, 416);
context.setFontSize(24);
context.setFillStyle(’#444444’);
context.textAlign = ‘center’;
context.fillText(’『知识分享标题』’, 260, 94);
context.stroke();
//绘制图片
context.draw();
//生成图片路径
setTimeout(function () {
wx.canvasToTempFilePath({
canvasId: ‘canvas’,
success: function (res) {
var tempFilePath = res.tempFilePath;
that.setData({
imagePath: tempFilePath,
});
console.log(tempFilePath)
},
fail: function (res) {
console.log(res);
}
});
}, 200);