浏览代码

fix: 修复tab在微信中无法正常显示的问题

zhenyulei 4 年之前
父节点
当前提交
4054904e4a
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/packages/tab/tab.vue

+ 6 - 4
src/packages/tab/tab.vue

@@ -250,10 +250,12 @@ export default {
       } else {
         this.initX = parseInt(this.navWidth * index);
       }
-      if (this.positionNav == 'top' || this.positionNav == 'bottom') {
-        this.$refs.navlist.scroll(this.initX - this.tapWidth, 0, 0);
-      } else {
-        this.$refs.navlist.scroll(0, this.initX - this.tapWidth);
+      if (this.$refs.navlist.scroll) {
+        if (this.positionNav == 'top' || this.positionNav == 'bottom') {
+          this.$refs.navlist.scroll(this.initX - this.tapWidth, 0, 0);
+        } else {
+          this.$refs.navlist.scroll(0, this.initX - this.tapWidth);
+        }
       }
       let items = this.$refs.items.children;
       for (let i = 0; i < items.length; i++) {