您好,欢迎来到尔游网。
搜索
您的当前位置:首页在uniapp微信小程序中保存图片到本地相册

在uniapp微信小程序中保存图片到本地相册

来源:尔游网

实现在uniapp微信小程序中点击按钮,保存图片到本地相册,具体实现方法:

template中

<button class="haibaobtn" @click="handledownload">保存图片</button>

js中

handledownload(){
const that = this
					uni.downloadFile({
						url: '图片地址',
						success: res => {
							if (res.statusCode === 200) {
								uni.saveImageToPhotosAlbum({
									filePath: res.tempFilePath,
									success: function() {
										uni.showToast({
											title: '保存成功',
											duration: 2000
										})

									},
									fail: function() {
										uni.showToast({
											title: '保存失败',
											duration: 2000
										})

									}
								})
							} else {
								uni.showToast({
									title: '保存失败',
									duration: 2000
								})
							}
						}
					})
}

手机运行:

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- axer.cn 版权所有 湘ICP备2023022495号-12

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务