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

 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'}"

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容