vant/docs/markdown/en-US/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

2.0 KiB

Tabbar

Install

import { Tabbar, TabbarItem } from 'vant';

Vue.component(Tabbar.name, Tabbar);
Vue.component(TabbarItem.name, TabbarItem);

Usage

Basic Usage

<van-tabbar v-model="active">
  <van-tabbar-item icon="shop">Tab</van-tabbar-item>
  <van-tabbar-item icon="chat" dot>Tab</van-tabbar-item>
  <van-tabbar-item icon="records" info="5">Tab</van-tabbar-item>
  <van-tabbar-item icon="gold-coin" info="20">Tab</van-tabbar-item>
</van-tabbar>
export default {
  data() {
    return {
      active: 0
    }
  }
}

Custom icon

Use icon slot to custom icon

<van-tabbar v-model="active">
  <van-tabbar-item icon="shop">
    <span>Custom</span>
    <img slot="icon" :src="active === 0 ? icon.active : icon.normal" />
  </van-tabbar-item>
  <van-tabbar-item icon="chat">Tab</van-tabbar-item>
  <van-tabbar-item icon="records">Tab</van-tabbar-item>
</van-tabbar>
export default {
  data() {
    return {
      active: 0,
      icon: {
        normal: '//img.yzcdn.cn/1.png',
        active: '//img.yzcdn.cn/2.png'
      }
    }
  }
}

Tabbar API

Attribute Description Type Default Accepted Values
v-model Index of current tab Number - -

Tabbar Event

Event Description Attribute
change Triggered when change active tab active: index of current tab

TabbarItem API

Attribute Description Type Default Accepted Values
icon Icon name String - Names from Icon Component
dot Whether to show red dot Boolean - -
info Info message String - -
url Link String - -
to Target route of the link, same as to of vue-router `String Object` -
replace If true, the navigation will not leave a history record String false -