想通过canvas画一张海报,但是获取的图片base64编码无法画到canvas上,现在将base64图片临时保存,但是临时保存的路径无法正常访问是什么原因?
async initCanvas() {
let systemInfo = await this.getSystemInfo();
this.ctx = uni.createCanvasContext('firstCanvas');
this.ctx.drawImage('/userPages/static/share/share.jpg', 0, 0, systemInfo.windowWidth, systemInfo.windowHeight);
let qrcodePath = await this.getBase64ImageInfo()
this.ctx.drawImage(qrcodePath, 0, 0, 216, 216);
this.ctx.draw()
},
getBase64ImageInfo() {
const fs = uni.getFileSystemManager()
var times = new Date().getTime();
var imgPath = wx.env.USER_DATA_PATH + '/share.png';
return new Promise((req, rej) => {
fs.writeFile({
filePath: imgPath,
data: this.share.icon.slice(22),
encoding: 'base64',
success: (res) => {
this.textImg = imgPath
req(imgPath)
}
})
})
},
这个时候报500错误,图片访问不到,base64真实可以用的
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。