微信小程序 图片转为base64编码

var imgUrl = e.detail.imgUrl//图片地址
if(imgUrl != ''){
  wx.getFileSystemManager().readFile({
    filePath: imgUrl, //地址
    encoding: 'base64', //编码格式
    success: res => {
      console.log('data:image/png;base64,' + res.data)//输出base64
    }
  })
}
posted @ 2022-05-24 11:23  老实巴交的搬砖户  阅读(562)  评论(0)    收藏  举报