一、首先要安装插件image-tools,插件地址:https://ext.dcloud.net.cn/plugin?id=123
npm i image-tools --save
二、引入
import {pathToBase64,base64ToPath} from 'image-tools'
三、应用
openImg(){//预览图片 let that = this;uni.showLoading({title: "加载中..."})var arr=[];base64ToPath(this.bimg).then(path => {console.log('----',path);uni.hideLoading()arr[0] = path;uni.previewImage({current: 0,urls: arr});}).catch(error => {// 图片加载失败uni.hideLoading()})},