uni-app中長按刪除


1、view代碼

<view class="imgShow" v-for="(item,index) in list" :key="index">
  <image :src="item.image_path" @touchstart.prevent="touchstart(index)" @touchend.prevent="touchend"></image>
</view>

2、script代碼

touchstart(index) {
  let that = this;
  clearInterval(this.Loop); //再次清空定時器,防止重復注冊定時器
    this.Loop = setTimeout(function() {
      uni.showModal({
        title: '刪除',
        content: '請問要刪除本條消息嗎?',
        success:async function(res) {
          if (res.confirm) {
            var id = that.list[index].id
            let data = await that.$http.post('api/shop/shop_qualification_image/delete',{
            'id':id,
          }).then(function(data){

            console.log('用戶點擊確定')

          }).catch(function(data){});

        } else if (res.cancel) {
          console.log('用戶點擊取消')
        }
      }
    });
  }.bind(this), 1000);
},
touchend() {
  clearInterval(this.Loop);
},

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM