Skip to content

Commit 3ebc731

Browse files
committed
docs(tab-bar): add value prop doc
1 parent 36c8d90 commit 3ebc731

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

document/components/docs/en-US/tab-bar.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The following demo code is [here](https://github.com/didi/cube-ui/tree/master/ex
1414

1515
- Basic usage
1616

17-
You can initialize `cube-tab-bar` by passing in the data structure of `tabs` as follows. You must use the `v-model` directive to select the corresponding tab. The value of the v-model argument must correspond to the label attribute of a tab in `cube-tab-bar`. The icon attribute is used as a class selector, which is generally used with icon-font class. It will dispatch `click` and `change` event at the proper time. The parameter is the label value corresponding to each selected tab.
17+
You can initialize `cube-tab-bar` by passing in the data structure of `tabs` as follows. You must use the `v-model` directive to select the corresponding tab. The value of the v-model argument must correspond to the `label`(after 1.12.5, use `value`) attribute of a tab in `cube-tab-bar`. The icon attribute is used as a class selector, which is generally used with icon-font class. It will dispatch `click` and `change` event at the proper time. The parameter is the `label`(after 1.12.5, is `value`) value corresponding to each selected tab.
1818

1919
```html
2020
<template>
@@ -108,7 +108,7 @@ The following demo code is [here](https://github.com/didi/cube-ui/tree/master/ex
108108

109109
### CubeTabBar & CubeTabPanels
110110

111-
Usually, our requirement is to display different panel as tabs are switched, so we need to use the `cube-tab-panels` component. `cube-tab-panels` must be nested with `cube-tab-panel`. The label values passed to `cube-tab` and `cube-tab-panel` must be the same, because it is necessary to create the relationship between tab with panel. They are linked by the same `v-model`.To see the effect, click on the `tab-basic` demo on the right.
111+
Usually, our requirement is to display different panel as tabs are switched, so we need to use the `cube-tab-panels` component. `cube-tab-panels` must be nested with `cube-tab-panel`. The `label`(after 1.12.5, use `value`) values passed to `cube-tab` and `cube-tab-panel` must be the same, because it is necessary to create the relationship between tab with panel. They are linked by the same `v-model`.To see the effect, click on the `tab-basic` demo on the right.
112112

113113
```html
114114
<template>
@@ -158,7 +158,7 @@ In fact, `cube-tab-bar` can be combined with many other cube-ui's components (su
158158
| Attribute | Description | Type | Demo | Default |
159159
| - | - | - | - | - |
160160
| value | Use v-model to select the corresponding tab when initializing. | String/Number | - | - |
161-
| data | For data rendered with `cube-tab-bar`, when using the built-in default slot, this parameter must be passed. Each item of the array is an Object type, including `label` and `icon`. If a custom slot is used, this value may not be passed | Array | [{label: 1, icon: 'cubeic-like'}, {label: 2, icon: 'cubeic-like'}] | [] |
161+
| data | For data rendered with `cube-tab-bar`, when using the built-in default slot, this parameter must be passed. Each item of the array is an Object type, including `label`, `icon` and `value`<sup>1.12.5+</sup>. If a custom slot is used, this value may not be passed | Array | [{label: 1, value: 1, icon: 'cubeic-like'}, {label: 2, value: 2, icon: 'cubeic-like'}] | [] |
162162
| showSlider | Whether to turn on the underscore follow effect | Boolean | true/false | false |
163163
| inline | Whether text and icons are displayed on one line | Boolean | true/false | false |
164164
| useTransition | Whether to use transition | Boolean | true/false | true |
@@ -167,20 +167,22 @@ In fact, `cube-tab-bar` can be combined with many other cube-ui's components (su
167167

168168
| Attribute | Description | Type | Needed | Default |
169169
| - | - | - | - | - |
170-
| label | Use it to determine which tab is clicked | String/Number | yes | - |
170+
| label | Use it to determine which tab is clicked before 1.12.5, after 1.12.5 just use to display text by default | String/Number | yes | - |
171+
| value | Use it to determine which tab is clicked<sup>1.12.5+</sup> | String/Number | no | `label` value |
171172

172173
- CubeTabPanels
173174

174175
| Attribute | Description | Type | Demo | Default |
175176
| - | - | - | - | - |
176177
| value | Use v-model to display the corresponding panels at initialization | String/Number | - | - |
177-
| data | For data rendered with `cube-tab-panels`, when using the built-in default slot, this parameter must be passed. Each item of the array is an Object type, including `label`. If a custom slot is used, this value may not be passed | Array | [{label: 1}, {label: 2}] | [] |
178+
| data | For data rendered with `cube-tab-panels`, when using the built-in default slot, this parameter must be passed. Each item of the array is an Object type, including `label` and `value`<sup>1.12.5+</sup>. If a custom slot is used, this value may not be passed | Array | [{label: 1, value: 1}, {label: 2, value: 2}] | [] |
178179

179180
- CubeTabPanel
180181

181182
| Attribute | Description | Type | Needed | Default |
182183
| - | - | - | - | - |
183184
| label | determine that the panels is displayed | String/Number | yes | - |
185+
| value | the key of panel, use it to determined selected value<sup>1.12.5+</sup> | String/Number | no | `label` value |
184186

185187
### Slot
186188

@@ -197,8 +199,8 @@ In fact, `cube-tab-bar` can be combined with many other cube-ui's components (su
197199

198200
| Event Name | Description | parameter |
199201
| - | - | - | - |
200-
| click | Dispatched when the tab is clicked | The label value of the tab which is selected |
201-
| change | Dispatched when tab changed | The label value of the tab which is selected |
202+
| click | Dispatched when the tab is clicked | The `label`/`value`<sup>1.12.5+</sup> value of the tab which is selected |
203+
| change | Dispatched when tab changed | The `label`/`value`<sup>1.12.5+</sup> value of the tab which is selected |
202204

203205
### Instance methods
204206

document/components/docs/zh-CN/tab-bar.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- 默认样式
1616

17-
传入如下 `tabs` 的数据结构便能初始化 `cube-tab-bar`,必须使用 `v-model` 指令来选中对应的 tab, v-model 的参数的值必须与某一项 tab 的 label 属性对应,icon 属性是用做于 class 选择器,一般是用字体图标样式,`cube-tab-bar` 在不同的时机派发 `click``change` 事件,参数则是每次选中的 tab 对应的 label 值。
17+
传入如下 `tabs` 的数据结构便能初始化 `cube-tab-bar`,必须使用 `v-model` 指令来选中对应的 tab, v-model 的参数的值必须与某一项 tab 的 label 属性对应(1.12.5 版本后是和 value 属性对应),icon 属性是用做于 class 选择器,一般是用字体图标样式,`cube-tab-bar` 在不同的时机派发 `click``change` 事件,参数则是每次选中的 tab 对应的 label 值(1.12.5 版本后是 value 值)
1818

1919
```html
2020
<template>
@@ -113,7 +113,7 @@
113113

114114
### CubeTabBar & CubeTabPanels
115115

116-
往往我们的需求是随着 tab 的切换显示不同的容器,这个时候需要搭配 `cube-tab-panels` 组件。`cube-tab-panels` 必须嵌套 `cube-tab-panel`,传入 `cube-tab``cube-tab-panel` 的label值必须一致,因为需要建立一个 tab 对应一个 panel 的关系。他们通过相同的 `v-model` 联动。查看效果可点击右边的 `tab-basic` 示例。
116+
往往我们的需求是随着 tab 的切换显示不同的容器,这个时候需要搭配 `cube-tab-panels` 组件。`cube-tab-panels` 必须嵌套 `cube-tab-panel`,传入 `cube-tab``cube-tab-panel` 的label值必须一致(1.12.5 版本后和 value 值一致),因为需要建立一个 tab 对应一个 panel 的关系。他们通过相同的 `v-model` 联动。查看效果可点击右边的 `tab-basic` 示例。
117117

118118
```html
119119
<template>
@@ -161,7 +161,7 @@ export default {
161161
| 参数 | 说明 | 类型 | 示例 | 默认值 |
162162
| - | - | - | - | - |
163163
| value | 使用 v-model,初始化时选中对应的 tab | String/Number | - | - |
164-
| data | 用于 `cube-tab-bar` 渲染的数据,当需要使用内置的默认插槽,此参数必传,数组的每一项是一个 Object 类型,包括 `label``icon`,如果使用自定义插槽,可不传此值 | Array | [{label: 1, icon: 'cubeic-like'}, {label: 2, icon: 'cubeic-like'}] | [] |
164+
| data | 用于 `cube-tab-bar` 渲染的数据,当需要使用内置的默认插槽,此参数必传,数组的每一项是一个 Object 类型,包括 `label``icon``value`(默认值等于 `label`)<sup>1.12.5+</sup>,如果使用自定义插槽,可不传此值 | Array | [{label: 1, value: 1, icon: 'cubeic-like'}, {label: 2, value: 2, icon: 'cubeic-like'}] | [] |
165165
| showSlider | 是否开启下划线跟随效果 | Boolean | true/false | false |
166166
| inline | 文字与图标是否显示在一行 | Boolean | true/false | false |
167167
| useTransition | 是否开启 transition 过渡 | Boolean | true/false | true |
@@ -170,20 +170,22 @@ export default {
170170

171171
| 参数 | 说明 | 类型 | 是否必传 | 默认值 |
172172
| - | - | - | - | - |
173-
| label | 用于判断哪个 tab 点击从而高亮 | String/Number || - |
173+
| label | 1.12.5 版本前作为哪个 tab 的值作为选中值,1.12.5 版本后主要用作展示 | String/Number || - |
174+
| value | 用于判断哪个 tab 的值作为选中值<sup>1.12.5+</sup> | String/Number || `label` 的值 |
174175

175176
- CubeTabPanels
176177

177178
| 参数 | 说明 | 类型 | 示例 | 默认值 |
178179
| - | - | - | - | - |
179180
| value | 使用 v-model,初始化时显示对应的 panels | String/Number | - | - |
180-
| data | 用于 `cube-tab-panels` 渲染的数据,当需要使用内置的默认插槽,此参数必传,数组的每一项是一个 Object 类型,包括 `label`,如果使用自定义插槽,可不传此值 | Array | [{label: 1}, {label: 2}] | [] |
181+
| data | 用于 `cube-tab-panels` 渲染的数据,当需要使用内置的默认插槽,此参数必传,数组的每一项是一个 Object 类型,包括 `label``value`<sup>1.12.5+</sup>,如果使用自定义插槽,可不传此值 | Array | [{label: 1, value: 1}, {label: 2, value: 2}] | [] |
181182

182183
- CubeTabPanel
183184

184185
| 参数 | 说明 | 类型 | 是否必传 | 默认值 |
185186
| - | - | - | - | - |
186187
| label | 用于显示 panel | String/Number || - |
188+
| value | panel 的 key 值,决定了选中的值<sup>1.12.5+</sup> | String/Number || `value` 的值 |
187189

188190
### 插槽
189191

@@ -200,8 +202,8 @@ export default {
200202

201203
| 事件名 | 说明 | 参数1 |
202204
| - | - | - | - |
203-
| click | 当 tab 被点击时派发 | 点中的tab的label值 |
204-
| change | 当点击不同的 tab 时派发 | 点中的tab的label值 |
205+
| click | 当 tab 被点击时派发 | 点中的tab的label/value<sup>1.12.5+</sup>值 |
206+
| change | 当点击不同的 tab 时派发 | 点中的tab的label/value<sup>1.12.5+</sup>值 |
205207

206208
### 实例方法
207209

0 commit comments

Comments
 (0)