neverland 371f6c1c7f [new feature] Toast support position prop (#244)
* [bugfix] Checkbox border render error in weixin browser

* [bugfix] TreeSelect dependency path error

* [bugfix] Swipe should clear autoplay timer when destroyed

* [bugfix] Optimize component dependency analyze when build style entry

* merge

* update yarn.lock

* update README.md

* update README.md

* update README.md

* update README.md

* update README.md

* [Doc] add more badges in README.md

* update README.md

* [bugfix] Address & Contact list style

* fix: contact test cases

* [bugfix] popup style missing when build style entry

* [bugfix] Search: onSearch event arguments missing

* [Doc] add demo pages

* update zan-doc@0.3.7

* fix: build entry error

* [Doc] add goods demo

* [bugfix] button primary background color

* [Doc] update doc detail

* [new feature] Coupon add 'showExchangeBar' prop && add empty style

* [new feature] Toast support `position` prop

* [new feature] Tabbar add 'info' prop
2017-10-24 22:41:06 -05:00

2.3 KiB

Tabbar 标签栏

使用指南

import { Tabbar, TabbarItem } from 'vant';

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

代码演示

基础用法

:::demo 基础用法

<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>
export default {
  data() {
    return {
      active: 0
    }
  }
}

:::

自定义图标

通过 icon slot 自定义图标

:::demo 自定义图标

<van-tabbar v-model="active2">
  <van-tabbar-item icon="shop">
    <span>自定义</span>
    <img slot="icon" :src="active2 === 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>
export default {
  data() {
    return {
      active2: 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 - -