学习目标:
1.小程序图片转base64学习内容:
base64({url,type}){ // url 为 小程序 图片 临时 地址,type为小程序图片拓展名
return new Promise((resolve, reject) => {
wx.getFileSystemManager().readFile({
filePath:url,
encoding: 'base64',
success: res => {
resolve('data:image/' + type.toLocaleLowerCase() + ';base64,' + res.data)
}
})
})
}
my_function: function(){
var that=this
that.base64({
url:tempFilePath, // 小程序 图片 临时地址
type:'(jpg|png|jpeg)$' // 指定 小程序图片 拓展名
}).then(res=>{
console.log("成功后打印我")
})
}