save-image-to-album.uvue 798 字节
Newer Older
张磊 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<template>
	<!-- #ifdef APP -->
	<scroll-view style="flex:1">
	<!-- #endif -->
		<image src="/static/uni.png" style="margin: 30rpx 200rpx;height:350rpx;width: 350rpx;"></image>
		<button style="margin: 30rpx;" @click="saveImage">将图片保存到相册</button>
	<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			saveImage() {
				uni.saveImageToPhotosAlbum({
					filePath:"/static/uni.png",
					success() {
						uni.showToast({
							icon:"none",
							title:"图片保存成功,请到相册查看"
						})
					},
					fail(e) {
						uni.showToast({
							icon:"none",
							title:"图片保存失败,"+JSON.stringify(e)
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>