vue-press-and-long-press
v1.0.1
Published
vue press and long press directive
Downloads
7
Maintainers
Readme
vue Press and longPress
在vue中区分点击和长按事件的自定义指令插件
- 支持PC、移动端
- 区分点击和长按事件
- 使用方便
Example
main.js:
import Vue from 'vue'
import pressAndLongPress from 'vue-press-and-long-press'
...
pressAndLongPress(Vue)
sample.vue:
<template>
...
<button v-longpress="incrementPlusTen" v-press="incrementPlusOne">{{value}}</button>
...
</template>
<script>
export default Vue.extend({
name: 'Home',
data() {
return {
value: 10,
}
},
methods: {
incrementPlusOne(e) {
console.log('点击增加1')
this.value++
},
incrementPlusTen(e) {
console.log('长按增加10')
this.value += 10
}
}
}
</script>