Browse Source

Tabs: get the correct tab through tab name (#13705)

iamkun 6 years ago
parent
commit
16311d1e32
1 changed files with 2 additions and 1 deletions
  1. 2 1
      packages/tabs/src/tab-bar.vue

+ 2 - 1
packages/tabs/src/tab-bar.vue

@@ -2,6 +2,7 @@
   <div class="el-tabs__active-bar" :class="`is-${ rootTabs.tabPosition }`" :style="barStyle"></div>
   <div class="el-tabs__active-bar" :class="`is-${ rootTabs.tabPosition }`" :style="barStyle"></div>
 </template>
 </template>
 <script>
 <script>
+  import { arrayFind } from 'element-ui/src/utils/util';
   export default {
   export default {
     name: 'TabBar',
     name: 'TabBar',
 
 
@@ -25,7 +26,7 @@
             return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
             return str.toLowerCase().replace(/( |^)[a-z]/g, (L) => L.toUpperCase());
           };
           };
           this.tabs.every((tab, index) => {
           this.tabs.every((tab, index) => {
-            let $el = this.$parent.$refs.tabs[index];
+            let $el = arrayFind(this.$parent.$refs.tabs, t => t.id.replace('tab-', '') === tab.name);
             if (!$el) { return false; }
             if (!$el) { return false; }
 
 
             if (!tab.active) {
             if (!tab.active) {