const base64 = base64; //base64格式图片
const time = new Date().getTime();
//USER_DATA_PATH:文件系统中的用户目录路径 (本地路径)
const imgPath = wx.env.USER_DATA_PATH + "/poster" + time + "" + ".png";
const imageData = base64.replace(/^data:image\/\w+;base64,/, "");
const file = wx.getFileSystemManager();
file.writeFileSync(imgPath, imageData, "base64");
console.log(imgPath);
//imgPath就是图片在本地的地址
//如需保存至本地
wx.saveImageToPhotosAlbum({
filePath: imgPath,
success: (res) => {
wx.showModal({
title: '照片已保存至相册',
content: '快去分享给小伙伴吧',
confirmText: '我知道了',
showCancel: false,
})
}
})
微信小程序真机调试或者上线后base64图片不显示
最新推荐文章于 2024-07-22 18:22:47 发布