icarusion/vue-book

page115标签页组件详解

Harhao opened this issue · 1 comments

为什么要在更新导航标签时判断 index == 0 这个条件??比较疑问

updateNav() {
      this.navList = [];
      const _this = this;
      this.getTabs().forEach((pane, index) => {
        _this.navList.push({
          label: pane.label,
          name: pane.name || index
        });
        if (!pane.name) {
          pane.name = index;
        }
         if (index == 0) {
          if (!_this.currentValue) {
             _this.currentValue = pane.name || index;
           }
         }
      });
      this.updateStatus();
    }

jhxxs commented

这么做是为了当tab组件没有设置activeKey或者activeKey为空时,默认显示第一个pane