touch 当绑定了swipeleft, swiperight事

2017-09-27  本文已影响0人  点_ba7a

 touch事件封装 

主要 如果是点击事件没有 moved事件 有bug

start(e) {

this.startx=''

this.endx=''

this.startx=e.touches[0].clientX

this.isMoved=false

console.log(this.startx);

},

endevent() {

if(this.isMoved) {

if(this.endx-this.startx<-40) {

this.left()

console.log('left');

}if(this.endx-this.startx>40) {

this.right()

console.log('right');

}

}

},

moveevent(e) {

if(e.touches[0].clientX) {

this.endx=e.touches[0].clientX

this.isMoved=true

}

console.log(this.isMoved);

},

当绑定了swipeleft, swiperight事件,滚动失效!#41

两种解决办法:

1.在全局配置中加上VueTouch.config.swipe = {direction: 'horizontal' }

2.在使用vue-touch的元素标签上直接加上 v-touch-options:swipe="{ direction:'horizontal'}"

上一篇 下一篇

猜你喜欢

热点阅读