base64图片在开发者工具模拟器中可以显示,手机上运行显示不了?
async drawCanvas() {
const ctx = uni.createCanvasContext('canvas', this);
// 绘制背景图
var path = await this.getImageInfoPromise('https://fyqgsm.top/static/wifi/bj1.jpg');
const canvasWidthPx = uni.upx2px(this.canvasWidth);
const canvasHeightPx = uni.upx2px(this.canvasHeight);
ctx.drawImage(path, 0, 0, canvasWidthPx, canvasHeightPx);
// 绘制固定位置的图片
ctx.drawImage(this.qrcode, canvasWidthPx / 6, canvasHeightPx / 5, canvasWidthPx / 6 * 4,
canvasWidthPx / 6 * 4); // 在(50, 50)位置绘制一张100x100的图片
// 绘制完成后,调用draw方法进行渲染
ctx.draw();
},
this.qrcode = 'data:image/jpeg;base64,' + res.response;
this.qrcode 为base64图片在手机上无法显示,path远程图片正常可以显示