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);
},