VUE监听左右滑动(vue-touch)
首先需要安装(vue-touch)
npm安装
npm install vue-touch@next --save
//main.js中引入全局使用:
import VueTouch from 'vue-touch'
Vue.use(VueTouch, {name: 'v-touch'})
使用方法
//html代码
<template>
<v-touch v-on:swipeleft="swiperleft" v-on:swiperight="swiperright" class="wrapper">
<!-- 需要监听的内容 -->
</v-touch>
</template>
JS
methods: {
swiperleft: function () {
console.log("左划")
},
swiperright: function () {
console.log("右滑")
},
}
有什么问题欢迎评论留言,我会及时回复你的