前端程序员

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

2019-03-29  本文已影响6人  余生在此

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

插件预览图

saveImg.gif

功能介绍

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

使用教程

1.插件代码拷贝

2.插件全局配置

import savefile from './components/saveFile.vue'

Vue.component('savefile',savefile)

3.插件使用

<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

上一篇 下一篇

猜你喜欢

热点阅读