1、安装:npm i image-tools --save
2、引入:import { pathToBase64, base64ToPath } from 'image-tools'
3、使用:图片转base64(注意事项:如果是网络路径需要先使用下载API下载下来)
pathToBase64(path).then(base64 => {
console.log(base64)
})
.catch(error => {
console.error(error)
})
4、使用:base64转图片
base64ToPath(base64).then(path => {
console.log(path)
})
.catch(error => {
console.error(error)
})