async getImageBase64_readFile(tempFilePath) {
const base64 = await new Promise(resolve => {
//获取全局唯一的文件管理器
wx.getFileSystemManager()
.readFile({ //读取本地文件内容
filePath: tempFilePath, // 文件路径
encoding: 'base64', // 返回格式
success: ({data}) => {
return resolve('data:image/png;base64,' + data);
},
fail(res) {
console.log('fail', res)
}
});
});
console.log('base64', base64)
this.$nextTick(()=>{
this.userImg=base64
})
},
小程序读取 wxfile://开头的临时文件(图片)
于 2023-10-24 16:48:25 首次发布