Vue下 touchstart touchend 事件无效失效解决办法
最新推荐文章于 2025-04-21 17:04:13 发布
原创
最新推荐文章于 2025-04-21 17:04:13 发布
·
9.2k 阅读
·
1
·
4
·
CC 4.0 BY-SA版权
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
文章标签:
#vue
#js
#vue.js
前端
专栏收录该内容
9 篇文章
订阅专栏
本文介绍了在Vue项目中遇到touchstart和touchend事件不起作用的状况,提供了解决方案:通过在事件绑定上添加.native.prevent修饰符,确保事件能够正常监听并触发。示例代码展示了如何在van-button组件上应用此方法,从而在移动端实现触摸开始和结束的监听功能。
摘要生成于
C知道
,由 DeepSeek-R1 满血版支持,
前往体验 >
Vue下 touchstart touchend 事件无效失效解决办法
:disabled="isLoading" plain type="info" @touchstart.native.prevent="touchstart" @touchend.native.prevent="touchend" style="width:40%;height: 40px;" round>对比原图
@touchstart.native.prevent=“touchstart”
@touchend.native.prevent=“touchend”
增加 .native.prevent
touchstart() {
console.log('touchstart')
},
touchend() {
console.log('touchend')
},