<view class="page_wrap"> <image class="poster_img" src="{{imgSrc}}" mode="" show-menu-by-longpress="true" /> </view> data: { imgSrc: null }, onLoad(query) { // console.log('onLoad============') this.initData(query) }, initData(query) { this.base64Src(query.base64Img, (tempFilePath) => { this.setData({ imgSrc: tempFilePath }) })} base64Src(base64data, fun) { const base64 = base64data; //base64格式图片 const time = new Date().getTime(); const imgPath = wx.env.USER_DATA_PATH + "/poster" + time + "share" + ".png"; // const imgPath = wx.env.USER_DATA_PATH + "/poster.jpeg"; //如果图片字符串不含要清空的前缀,可以不执行下行代码. const imageData = base64.replace(/^data:image\/\w+;base64,/, ""); const file = wx.getFileSystemManager(); // 获取全局唯一的文件管理器 file.writeFileSync(imgPath, imageData, "base64"); fun(imgPath); }, 生成的临时 图片路径 在ios上显示不出来,安卓可以 生成的临时地址:http://usr/poster1671681920883share.png
微信小程序苹果IOS手机无法加载显示临时图片路径ios手机有毒呀加载不了临时图片路径,Android的就可以~ 大哥有ios手机的可以试试 [图片]
2022-12-22