Skip to content

Commit 36c8d90

Browse files
committed
feat(tab-panels): support value prop for tab-panel
1 parent ff0838f commit 36c8d90

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/components/tab-panels/tab-panel.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
label: {
1414
type: [String, Number],
1515
required: true
16+
},
17+
value: {
18+
type: [String, Number],
19+
default() {
20+
return this.label
21+
}
1622
}
1723
},
1824
mounted () {

src/components/tab-panels/tab-panels.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<cube-tab-panel
66
v-for="(item, index) in data"
77
:label="item.label"
8-
:key="item.label">
8+
:value="item.value"
9+
:key="item.value || item.label">
910
{{item.label}}
1011
</cube-tab-panel>
1112
</slot>
@@ -42,8 +43,8 @@
4243
this._move(this.value)
4344
},
4445
methods: {
45-
_move(label) {
46-
const curIndex = findIndex(this.panels, panel => panel.label === label)
46+
_move(value) {
47+
const curIndex = findIndex(this.panels, panel => panel.value === value)
4748
/* istanbul ignore if */
4849
if (curIndex === INDEX_OUT_OF_BOUNDARY) {
4950
return

0 commit comments

Comments
 (0)