您的位置:首页 > 房产 > 家装 > uni-app 微信 支付宝 小程序 使用 longpress 实现长按删除功能,非常简单 只需两步

uni-app 微信 支付宝 小程序 使用 longpress 实现长按删除功能,非常简单 只需两步

2024/10/6 18:32:40 来源:https://blog.csdn.net/qq_52602294/article/details/139167837  浏览:    关键词:uni-app 微信 支付宝 小程序 使用 longpress 实现长按删除功能,非常简单 只需两步

1、先看效果

2、直接上代码 ui结构

<view class="bind" @longpress="deleteImage" :data-index="index"><view class="bind_left">绑定设备</view><view class="bind_right"><view class="bind_top"><text class="bind_title">F039</text><text>一拖四充电桩</text></view><view class="bind_body"><text class="bind_title">SN00000000000125 | 1F01</text><image class="icon_imaeg1" src="../../static/saoma/back.png" mode="aspectFit"></image></view><view class="bind_bottom"><view class="bottom_title1">1</view><view class="bottom_title1">2</view><view class="bottom_title1">3</view></view></view></view>

 3、js 逻辑

// 长按删除
const deleteImage = (e) => {console.log('长按', e);const index = e.currentTarget.dataset.index; //获取当前长按图片下标uni.showModal({title: '提示',content: '确定删除吗?',success: function (res) {if (res.confirm) {uni.showToast({title: '删除成功',icon: 'none'});} else if (res.cancel) {uni.showToast({title: '取消删除',icon: 'none'});console.log('用户点击取消');}}});
};

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com