1. 程式人生 > >bertterScroll移動端一些配置

bertterScroll移動端一些配置

_initScroll() {
  if (!this.$refs.wrapper) {
    return
}
//bertterScroll禁用所有元素的click,可用這個方法preventDefaultException解開

  this.scroll = new BScroll(this.$refs.wrapper, {
    probeType: this.probeType,
    click: this.click,
    eventPassthrough: 'horizontal',
    mouseWheel: true,
    scrollX: true,
    preventDefaultException
: {tagName: /^(IMG|INPUT|TEXTAREA|BUTTON|SELECT|SPAN)$/}//標籤可以用原生click了
}); this.scrollEvents.$on('scrollTo',(msg)=>{ this.scroll.scrollTo(0,msg,800) });
//禁用瀏覽器的預設行為,ios微信端頁面被整體拖動的問題,
passive: false可以相容安卓與ios
document.addEventListener('touchmove', function (e) {
  //取消事件的預設動作
e.preventDefault();
}, {passive
: false})