博客 / 詳情

返回

vux scroller在iOS13上,一停止滑動就跳到頂部

問題: vux scroller在iOS13上,一停止滑動就跳到頂部

找了下解決辦法,最後找到原文這個鏈接,親測有效:
https://blog.csdn.net/sllailc...


在 node_modules_vux-xscroll@3.1.12@vux-xscrollbuildcmdsimulate-scroll.js下的getScrollTop方法如下
這裏路徑可能不完全一樣,反正就是源碼庫裏的vux-xscroll裏的simulate-scroll.js文件

getScrollTop: function() {
    var transY = window.getComputedStyle(this.container)[transform].match(/[-\d\.*\d*]+/g);
    return transY ? Math.round(transY[5]) === 0 ? 0 : -Math.round(transY[5]) : 0;
},

解決辦法:

將\node_modules\_vux-xscroll@3.1.12@vux-xscroll\build\cmd\simulate-scroll.js下的getScrollTop方法裏面的正則表達式替換成下面(/[-\d\.*\d*e\-\d]+/g )的就可以了。**

 getScrollTop: function() {
    // var transY = window.getComputedStyle(this.container)[transform].match(/[-\d\.*\d*]+/g);
    var transY = window.getComputedStyle(this.container)[transform].match(/[-\d\.*\d*e\-\d]+/g);
    return transY ? Math.round(transY[5]) === 0 ? 0 : -Math.round(transY[5]) : 0;
  },
user avatar
0 位用戶收藏了這個故事!

發佈 評論

Some HTML is okay.