通过touch事件,监听
<swiper class="screen-swiper round-dot" indicator-active-color="#fff" :current="TabCur" @change="changebar"
:style="'height:'+ scrollH +'px;'">
<swiper-item @touchmove="stopTouchMove">
<scroll-view scroll-y="true" :style="'height:' + scrollH + 'px;'" @scroll="scroll" @touchend="touchEnd" @touchstart="touchstart">
created先声明
created() {
this.touch = {};
this.horizontal = 'horizontal';
this.vertical = 'vertical';
}
绑定touch事件
touchstart(e) {
this.touch.dirction = undefined;
},
touchEnd(e) {
this.touch.dirction = undefined;
}
windown.event解决ie兼容问题
stopTouchMove() {
//控制轮播图
// console.log(this.touch);
// w3c的方法是e.stopPropagation(),IE则是使用e.cancelBubble = true
if (this.touch.dirction === this.vertical) {
console.log(window.event)
window.event ? (window.event.cancelBubble = true) : e.stopPropagation();
}
}
scroll监听滚动
scroll(e) {
// 滚动方向为竖直方向
// console.log('scroll');
this.touch.dirction = this.vertical;
}