显示BASE64图片在真机上显示不出来,模拟器上就可以

发布于 6 年前作者 liangxiuying17740 次浏览最后编辑 6 年前来自 ask
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)
  }
})
2 回复
xiulan06
xiulan061 楼6 年前

提供一下能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

gang82
gang822 楼4 年前

mark