vant/docs/markdown/zh-CN/tabbar.md
neverland d8b6ad7d54
[new feature] add i18n support (#310)
* fix: Tabbar icon line-height

* [new feature] progress add showPivot prop

* [new feature] TabItem support vue-router

* [new feature] update document header style

* [Doc] add toast english ducoment

* [new feature] add i18n support

* feat: Extract demos from markdown

* feat: Base components demos

* [new feature] complete demo extract & translate

* [fix] text cases

* fix: add deepAssign test cases

* fix: changelog detail

* [new feature] AddressEdit support i18n
2017-11-15 20:08:51 -06:00

88 lines
2.0 KiB
Markdown

## Tabbar 标签栏
### 使用指南
``` javascript
import { Tabbar, TabbarItem } from 'vant';
Vue.component(Tabbar.name, Tabbar);
Vue.component(TabbarItem.name, TabbarItem);
```
### 代码演示
#### 基础用法
```html
<van-tabbar v-model="active">
<van-tabbar-item icon="shop">标签</van-tabbar-item>
<van-tabbar-item icon="chat" dot>标签</van-tabbar-item>
<van-tabbar-item icon="records" info="5">标签</van-tabbar-item>
<van-tabbar-item icon="gold-coin" info="20">标签</van-tabbar-item>
</van-tabbar>
```
```javascript
export default {
data() {
return {
active: 0
}
}
}
```
#### 自定义图标
通过 icon slot 自定义图标
```html
<van-tabbar v-model="active">
<van-tabbar-item icon="shop">
<span>自定义</span>
<img slot="icon" :src="active === 0 ? icon.active : icon.normal" />
</van-tabbar-item>
<van-tabbar-item icon="chat">标签</van-tabbar-item>
<van-tabbar-item icon="records">标签</van-tabbar-item>
</van-tabbar>
```
```javascript
export default {
data() {
return {
active: 0,
icon: {
normal: '//img.yzcdn.cn/1.png',
active: '//img.yzcdn.cn/2.png'
}
}
}
}
```
### Tabbar API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| v-model | 当前选中标签的索引 | `Number` | - | - |
### Tabbar Event
| 事件名 | 说明 | 参数 |
|-----------|-----------|-----------|
| change | 切换标签时触发 | active: 当前选中标签 |
### TabbarItem API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| icon | 图标名称 | `String` | - | Icon 组件中可用的类型 |
| dot | 是否显示小红点 | `Boolean` | - | - |
| info | 图标右上角提示信息 | `String` | - | - |
| url | 跳转链接 | `String` | - | - |
| to | 路由跳转对象,同 `vue-router` 的 to | `String | Object` | - | - |
| replace | 跳转时是否替换当前 history | `String` | `false` | - |