比如v-touch的滑动切换
<v-touch
class="touch"
v-on:swipeup="flag && onSwipeUp()"
v-on:swipedown="flag && onSwipeDown()">
<transition
mode="out-in"
:enter-active-class="animatedIn"
:leave-active-class="animatedOut"
:duration="{enter:800, leave:300}">
<router-view></router-view>
</transition>
</v-touch>
data() {
flag: true, // 用于控制点击切换页面后延时内是否可以点击(1.3s)
timerID: null, // 定时器
}
给事件绑定一个flag(默认为true)
// 上划事件
onSwipeUp() {
this.flag = false;
this.timerID = setTimeout(function () {
that.flag = true
},1000)
},
// 清除定时器
destroyed () {
clearTimeout(this.timerID)
},
// 在页面挂载的时候把定时器清除
mounted() {
this.destroyed ()
},