## Tabs ### Install ``` javascript import { Tab, Tabs } from 'vant'; Vue.use(Tab); Vue.use(Tabs); ``` ### Usage #### Basic Usage By default, the first tab is actived. You can set `active` attribute on `van-tabs` to active specified tab. ```html content of tab {{ index }} ``` ```js export default { data() { return { active: 2 }; } } ``` #### Swipe Tabs By default more than 4 tabs, you can scroll through the tabs. You can set `swipe-threshold` attribute to customize threshold number. ```html content of tab {{ index }} ``` #### Disabled Tab You can set `disabled` attribute on the corresponding `van-tab`. ```html content of tab {{ index }} ``` ```javascript export default { methods: { onClickDisabled() { Toast('Disabled!'); } } }; ``` #### Card Style Tabs styled as cards. ```html content of tab {{ index }} ``` #### Click Event You can bind `click` event on `van-tabs`, the event handler function has one parameters: index of click tab. ```html content of tab {{ index }} ``` ```javascript export default { methods: { handleTabClick(index) { Toast(index); } } }; ``` #### Sticky In sticky mode, the tab will be fixed to top when scroll to top ```html 内容 {{ index }} ``` ### Tabs API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | type | There are two style tabs, set this attribute to change tab style | `String` | `line` | `card` | | active | Index of active tab | `String` `Number` | `0` | - | | duration | Toggle tab's animation time | `Number` | `0.2` | - | - | | swipe-threshold | Set swipe tabs threshold | `Number` | `4` | - | - | ### Tab API | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | title | Tab title | `String` | - | - | | disabled | Whether disabled current tab | `Boolean` | `false` | - | ### Tabs Event | Event | Description | Attribute | |-----------|-----------|-----------| | click | Triggered when click tab | index:index of current tab | | disabled | Triggered when click disabled tab | index:index of current tab |