PC端的项目写习惯了
突然写手机端的朋友 自然就会不太了解各类事件
在手机中 存在用户长按元素的情况 我们可以通过longpress进行监听
参考代码如下
<template>
<view>
<text @longpress="longpress(title)">{{ title }}</text>
</view>
</template>
<script>
export default {
data() {
return {
title: '捕获用户长按元素数据'
}
},
methods: {
longpress(title){
console.log(title);
}
}
}
</script>
<style scoped lang="scss">
</style>