weex 长按图片保存

// 页面部分


<image resize="cover"
@touchstart="start(index)" //点击图片开始
@touchend="end" //点击图片结束
:src="v.src" :style="{ height: height + 'px', width: width + 'px'}">

提示// ios中需要配置权限 在xcode info.plist 加入NSPhotoLibraryAddUsageDescription 从而获取保存图片权限

//js部分 method里面

          start (index) {
            const self = this
            this.index  = index
            self.isShow = setTimeout(() => {
                    //这是weex官方提供的保存图片
                self.$refs['img'].save(function(result) {
                        modal.toast({
                        message: `保存成功`,
                        duration: 0.3
                    })
                });
            }, 1000);
        },
        end () {
            clearInterval(this.isShow)
        }
posted @ 2018-11-29 11:53  -http  阅读(739)  评论(0编辑  收藏  举报