MSIPO技术圈 首页 IT技术 查看内容

uniapp中预览base64图片

2024-03-25

一、首先要安装插件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()
					})
					
			},

相关阅读

热门文章

    手机版|MSIPO技术圈 皖ICP备19022944号-2

    Copyright © 2024, msipo.com

    返回顶部