显示BASE64图片在真机上显示不出来,模拟器上就可以
发布于 5 年前 作者 liangxiuying 17527 次浏览 来自 问答
var base64 = res.data.img;
//通过写文件接口把BASE64的数据转为图片
 
const fileManager = wx.getFileSystemManager();
fileManager.writeFile({
  filePath: wx.env.USER_DATA_PATH + '/test.png',
  data: base64,
  encoding: 'base64',
  success: res => {
    if(this.data.imgurl){
      this.setData({
        imgurl: ''
      })
    }
    this.imagePath = wx.env.USER_DATA_PATH + '/test.png?t=' + new Date().getTime()
    console.log('this.imagePath:' + this.imagePath);
    this.setData({
      imgurl: this.imagePath
    })
  },
  fail: err => {
    console.error(err)
  }
})
回到顶部