uniapp如何实现长按删除

发布时间:2022-05-23 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了uniapp如何实现长按删除脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

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

uniapp如何实现长按删除

本教程操作环境: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如何实现长按删除的详细内容,更多请关注脚本宝典其它相关文章

脚本宝典总结

以上是脚本宝典为你收集整理的uniapp如何实现长按删除全部内容,希望文章能够帮你解决uniapp如何实现长按删除所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:uni-app