uniapp实现长按删除的方法:使用组件确定删除,代码为【this.Loop = setTimeout(function() {uni.showModal({title: '删除',content: '请问要删除本条消息吗?',】。

本教程操作环境:windows7系统、uni-app2.5.1版本、thinkpad t480电脑。
推荐(免费):uni-app开发教程
uniapp实现长按删除的方法:
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);
},相关免费学习推荐:php编程(视频)
以上就是uniapp如何实现长按删除的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号