[new feature] Tabs: support switch tabs with swipe gestrue in the content (#694)

This commit is contained in:
张敏
2018-03-15 10:17:51 +08:00
committed by neverland
parent f13a0779fd
commit 5cdf3b1d79
8 changed files with 137 additions and 8 deletions
+12 -2
View File
@@ -58,6 +58,14 @@
</van-tab>
</van-tabs>
</demo-block>
<demo-block :title="$t('title8')">
<van-tabs :active="active" swipeable>
<van-tab :title="$t('tab') + index" v-for="index in tabs" :key="index">
{{ $t('content') }} {{ index }}
</van-tab>
</van-tabs>
</demo-block>
</demo-section>
</template>
@@ -71,7 +79,8 @@ export default {
title4: '样式风格',
title5: '点击事件',
title6: '粘性布局',
title7: '自定义标签'
title7: '自定义标签',
title8: '滑动切换'
},
'en-US': {
tab: 'Tab ',
@@ -81,7 +90,8 @@ export default {
title4: 'Card Style',
title5: 'Click Event',
title6: 'Sticky',
title7: 'Custom Tab'
title7: 'Custom Tab',
title8: 'Swipeable'
}
},
+14
View File
@@ -124,6 +124,18 @@ Use title slot to custom tab title
</van-tabs>
```
#### Swipeable
In swipeable mode, you can switch tabs with swipe gestrue in the content
```html
<van-tabs :active="active" swipeable>
<van-tab v-for="index in 4" :title="'tab ' + index">
content {{ index }}
</van-tab>
</van-tabs>
```
### Tabs API
| Attribute | Description | Type | Default | Accepted Values |
@@ -132,6 +144,8 @@ Use title slot to custom tab title
| 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` | - | - |
| sticky | Whether to use sticky mode | `Boolean` | `false` | - |
| swipeable | Whether to switch tabs with swipe gestrue in the content | `Boolean` | `false` | - |
### Tab API
+13
View File
@@ -124,6 +124,18 @@ export default {
</van-tabs>
```
#### 滑动切换
通过`swipeable`属性可以开启滑动切换tab
```html
<van-tabs :active="active" swipeable>
<van-tab v-for="index in 4" :title="'选项 ' + index">
内容 {{ index }}
</van-tab>
</van-tabs>
```
### Tabs API
| 参数 | 说明 | 类型 | 默认值 | 可选 |
@@ -133,6 +145,7 @@ export default {
| duration | 切换 tab 的动画时间 | `Number` | `0.2` | - |
| swipe-threshold | 滚动阀值,设置 Tab 超过多少个可滚动 | `Number` | `4` | - |
| sticky | 是否使用粘性定位布局 | `Boolean` | `false` | - |
| swipeable | 是否可以滑动内容切换 | `Boolean` | `false` | - |
### Tab API