<template>
<view>
<view v-for="item in arr" :key="item" @touchstart.prevent="touchstart(item)" style="text-align: center;"
@touchend.prevent="touchend">{{item}}</view>
</view>
</template>
<script>
export default {
data() {
return {
arr: [1, 2, 3, 4, 5, 6]
}
},
onLoad() {
},
methods: {
touchstart(index) {
let that = this;
clearInterval(this.Loop); //再次清空定时器,防止重复注册定时器
console.log(111, index)
this.Loop = setTimeout(function() {
uni.showModal({
title: '删除',
content: '请问要删除本条消息吗?',
success: function(res) {
if (res.confirm) {
console.log(1324213412)
that.arr = that.arr.filter(item => item != index)
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}.bind(this), 1000);
},
touchend() {
console.log('结束')
clearInterval(this.Loop);
}
}
}
</script>
<style>
</style>
uniapp长按删除,或其他操作
最新推荐文章于 2024-05-24 10:21:21 发布