webapp长按保存图片到本地(vue)

html

<img @touchstart="start" class="ppimg" :src="imgUrl" alt="">

js(methods)

start() {
      var that = this;
      this.longClick = 0;
      this.timeOutEvent = setTimeout(function() {
        that.longClick = 1;
        that.downImg()
      }, 500);
    },
downImg(){
      if(!window.plus) return;
      plus.gallery.save(this.imgUrl, function () {
        alert('保存成功!');
      },function(){
        alert('保存失败,请重试!');
      });
    },

js(data)

data() {
    return {
      imgUrl: "",
      longClick: 0,
      timeOutEvent: 0
    };
  },

猜你喜欢

转载自blog.csdn.net/weixin_36185028/article/details/103063731