4***@qq.com
4***@qq.com
  • 发布:2019-03-29 14:22
  • 更新:2019-05-19 00:20
  • 阅读:12765

uni-app项目保存图片到相册

分类:uni-app

uni-app项目保存图片

github地址,喜欢的可以star下哦

插件预览图

功能介绍

1.长按保存图片
2.右下角图片点击保存图片
3.点击图片可以隐藏图片

使用教程

1.插件代码拷贝

  • 下载后把components目录下saveFile.vue文件拷贝到自己项目目录下

2.插件全局配置

  • 在项目里main.js中配置如下代码
import savefile from './components/saveFile.vue'  

Vue.component('savefile',savefile)  

3.插件使用

  • vue页面使用
<template>  
    <view>  
        <!-- 预览图片 -->  
        <savefile v-if="isShowPhoto" :url="qrUrl" @hide="hidePhoto"></savefile>  
    </view>  
</template>  

<script>  
export default {  
    data() {  
        return {  
            qrUrl:'/static/img/img1.jpg',  
            isShowPhoto:true,  
        };  
    },  
    onLoad() {},  
    methods: {  
        hidePhoto(){  
            this.isShowPhoto = false;  
            uni.showToast({  
                title:'图片已隐藏',  
                icon:'none'  
            })  
        }  
    }  
};  
</script>  
兼容性

uni-app项目中使用都兼容 除了H5

0 关注 分享

要回复文章请先登录注册

忘记我是谁

忘记我是谁

https://uniapp.dcloud.io/api/media/image?id=saveimagetophotosalbum vendor.js:581 支付宝小程序 暂不支持saveImageToPhotosAlbum
2019-05-19 00:20