在进行app开发中,使用uni.previewImage无法对后端返回的base64 格式的图片进行预览,H5却可以正常预览
解决方法:
将 base64 格式的图片转化为文件路径
1.插件市场下载:image-tools
2.页面中引用
import { pathToBase64, base64ToPath } from '../../js/image-tools/index.js'
3.示例
base64ToPath(item.uri).then(item => {
let imgs = [];
imgs[0] = item;
uni.previewImage({
current: 0,
urls: imgs
});
})