收藏
回答

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

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 个回答

  • 2018-11-27

    mark

    2018-11-27
    有用
    回复
  • 是小白啊
    是小白啊
    2018-11-05

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

    2018-11-05
    有用
    回复 2
    • Sammy Li
      Sammy Li
      2018-11-05

      处理了,谢谢


      2018-11-05
      回复
    • 啊哈
      啊哈
      2020-01-13回复Sammy Li
      怎么处理的
      2020-01-13
      回复
登录 后发表内容