Commit 26b2cfa02f3c8099a8663541dcbb7c6a36ef07f6
1 parent
d6e14b11
fixed #5377
Showing
2 changed files
with
23 additions
and
2 deletions
Show diff stats
src/components/tabs/pane.vue
src/components/tabs/tabs.vue
| @@ -96,6 +96,10 @@ | @@ -96,6 +96,10 @@ | ||
| 96 | default: false | 96 | default: false |
| 97 | }, | 97 | }, |
| 98 | beforeRemove: Function, | 98 | beforeRemove: Function, |
| 99 | + // Tabs 嵌套时,用 name 区分层级 | ||
| 100 | + name: { | ||
| 101 | + type: String | ||
| 102 | + }, | ||
| 99 | }, | 103 | }, |
| 100 | data () { | 104 | data () { |
| 101 | return { | 105 | return { |
| @@ -170,7 +174,20 @@ | @@ -170,7 +174,20 @@ | ||
| 170 | methods: { | 174 | methods: { |
| 171 | getTabs () { | 175 | getTabs () { |
| 172 | // return this.$children.filter(item => item.$options.name === 'TabPane'); | 176 | // return this.$children.filter(item => item.$options.name === 'TabPane'); |
| 173 | - return findComponentsDownward(this, 'TabPane'); | 177 | + const AllTabPanes = findComponentsDownward(this, 'TabPane'); |
| 178 | + const TabPanes = []; | ||
| 179 | + | ||
| 180 | + AllTabPanes.forEach(item => { | ||
| 181 | + if (item.tab && this.name) { | ||
| 182 | + if (item.tab === this.name) { | ||
| 183 | + TabPanes.push(item); | ||
| 184 | + } | ||
| 185 | + } else { | ||
| 186 | + TabPanes.push(item); | ||
| 187 | + } | ||
| 188 | + }); | ||
| 189 | + | ||
| 190 | + return TabPanes; | ||
| 174 | }, | 191 | }, |
| 175 | updateNav () { | 192 | updateNav () { |
| 176 | this.navList = []; | 193 | this.navList = []; |