Browse Source

fix: 修改tab组件在微信浏览器中不显示的问题

zhenyulei 4 years ago
parent
commit
5264e72b4c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/packages/tab/tab.vue

+ 2 - 2
src/packages/tab/tab.vue

@@ -161,14 +161,14 @@ export default {
         const tapWidth = this.$refs.navlist.offsetWidth;
         this.navWidth = currWidth;
         this.initX = currLeft;
-        this.$refs.navlist.scroll(currLeft - tapWidth / 2 + currWidth / 2, 0);
+        this.$refs.navlist.scroll && this.$refs.navlist.scroll(currLeft - tapWidth / 2 + currWidth / 2, 0);
       } else {
         const currTop = currEle.offsetTop;
         const currHeight = currEle.offsetHeight;
         const tapHeight = this.$refs.navlist.offsetHeight;
         this.navWidth = currHeight;
         this.initX = currTop;
-        this.$refs.navlist.scroll(0, currTop - tapHeight / 2 + currHeight / 2);
+        this.$refs.navlist.scroll && this.$refs.navlist.scroll(0, currTop - tapHeight / 2 + currHeight / 2);
       }
     },
     switchTab: function (index, event, disable) {