前言
在很多时候,我们需要图片的base64码,一般利用自己封装的function,但是微信小程序中可以利用 wx.getFileSystemManager().readFile
代码
//转base64
wx.getFileSystemManager().readFile({
filePath: imgpath,// 图片地址 本地or网络
encoding: "base64",
success: res => {
consol.log(res.data)// res.data就是转换完的base64
},
fail: res => {
}
})