Procházet zdrojové kódy

fix: 修复切换逻辑问题

zhangyuhan před 1 rokem
rodič
revize
2d26ba0354
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      src/custom-tab-bar/index.vue

+ 4 - 2
src/custom-tab-bar/index.vue

@@ -43,10 +43,12 @@ export default {
     ...mapGetters('tabbar', ['activeTabKey', 'tabbars'])
   },
   methods: {
+    ...mapMutations('tabbar', ['setSwitchTab']),
     ...mapActions('tabbar', ['doSwitchTab']),
     checkActiveTabbar ()  {
-      const activeKey = this.getComputedActiveKey(this.activeTabKey || this.tabbars[0].key)
-      this.doSwitchTab(activeKey)
+      const defaultKey = this.activeTabKey || (this.tabbars[0] ? this.tabbars[0].key : '')
+      const activeKey = this.getComputedActiveKey(defaultKey)
+      this.setSwitchTab(activeKey)
     },
     getComputedActiveKey (defaultActive = '') {
       let active = defaultActive