/*! For license information please see 4624.41278eca.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["4624"],{75363:function(s,a,n){"use strict";n.r(a);var t=n("80681");let l=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
Used to switch between different pages.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Tabbar, TabbarItem } from 'vant';\n\nconst app = createApp();\napp.use(Tabbar);\napp.use(TabbarItem);\n
\n<van-tabbar v-model="active">\n <van-tabbar-item icon="home-o">Tab</van-tabbar-item>\n <van-tabbar-item icon="search">Tab</van-tabbar-item>\n <van-tabbar-item icon="friends-o">Tab</van-tabbar-item>\n <van-tabbar-item icon="setting-o">Tab</van-tabbar-item>\n</van-tabbar>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const active = ref(0);\n return { active };\n },\n};\n
\n<van-tabbar v-model="active">\n <van-tabbar-item name="home" icon="home-o">Tab</van-tabbar-item>\n <van-tabbar-item name="search" icon="search">Tab</van-tabbar-item>\n <van-tabbar-item name="friends" icon="friends-o">Tab</van-tabbar-item>\n <van-tabbar-item name="setting" icon="setting-o">Tab</van-tabbar-item>\n</van-tabbar>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const active = ref('home');\n return { active };\n },\n};\n
\n<van-tabbar v-model="active">\n <van-tabbar-item icon="home-o">Tab</van-tabbar-item>\n <van-tabbar-item icon="search" dot>Tab</van-tabbar-item>\n <van-tabbar-item icon="friends-o" badge="5">Tab</van-tabbar-item>\n <van-tabbar-item icon="setting-o" badge="20">Tab</van-tabbar-item>\n</van-tabbar>\n
\nUse icon
slot to custom icon.
<van-tabbar v-model="active">\n <van-tabbar-item badge="3">\n <span>Custom</span>\n <template #icon="props">\n <img :src="props.active ? icon.active : icon.inactive" />\n </template>\n </van-tabbar-item>\n <van-tabbar-item icon="search">Tab</van-tabbar-item>\n <van-tabbar-item icon="setting-o">Tab</van-tabbar-item>\n</van-tabbar>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const active = ref(0);\n const icon = {\n active: 'https://fastly.jsdelivr.net/npm/@vant/assets/user-active.png',\n inactive:\n 'https://fastly.jsdelivr.net/npm/@vant/assets/user-inactive.png',\n };\n return {\n icon,\n active,\n };\n },\n};\n
\n<van-tabbar v-model="active" active-color="#ee0a24">\n <van-tabbar-item icon="home-o">Tab</van-tabbar-item>\n <van-tabbar-item icon="search">Tab</van-tabbar-item>\n <van-tabbar-item icon="friends-o">Tab</van-tabbar-item>\n <van-tabbar-item icon="setting-o">Tab</van-tabbar-item>\n</van-tabbar>\n
\n<van-tabbar v-model="active" @change="onChange">\n <van-tabbar-item icon="home-o">Tab 1</van-tabbar-item>\n <van-tabbar-item icon="search">Tab 2</van-tabbar-item>\n <van-tabbar-item icon="friends-o">Tab 3</van-tabbar-item>\n <van-tabbar-item icon="setting-o">Tab 4</van-tabbar-item>\n</van-tabbar>\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const active = ref(0);\n const onChange = (index) => showToast(`Tab ${index}`);\n return {\n icon,\n onChange,\n };\n },\n};\n
\n<router-view />\n\n<van-tabbar route>\n <van-tabbar-item replace to="/home" icon="home-o">Tab</van-tabbar-item>\n <van-tabbar-item replace to="/search" icon="search">Tab</van-tabbar-item>\n</van-tabbar>\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model | \nIdentifier of current tab | \nnumber | string | \n0 | \n
fixed | \nWhether to fixed bottom | \nboolean | \ntrue | \n
border | \nWhether to show border | \nboolean | \ntrue | \n
z-index | \nZ-index | \nnumber | string | \n1 | \n
active-color | \nColor of active tab item | \nstring | \n#1989fa | \n
inactive-color | \nColor of inactive tab item | \nstring | \n#7d7e80 | \n
route | \nWhether to enable route mode | \nboolean | \nfalse | \n
placeholder | \nWhether to generate a placeholder element when fixed | \nboolean | \nfalse | \n
safe-area-inset-bottom | \nWhether to enable bottom safe area adaptation | \nboolean | \nfalse | \n
before-change | \nCallback function before changing tab, return false to prevent change, support return Promise | \n(name: number | string) => boolean | Promise<boolean> | \n- | \n
Event | \nDescription | \nArguments | \n
---|---|---|
change | \nEmitted when changing active tab | \nactive: number | string | \n
Attribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
name | \nIdentifier | \nnumber | string | \nItem index | \n
icon | \nIcon name | \nstring | \n- | \n
icon-prefix | \nIcon className prefix | \nstring | \nvan-icon | \n
dot | \nWhether to show red dot | \nboolean | \n- | \n
badge | \nContent of the badge | \nnumber | string | \n\'\' | \n
badge-props | \nProps of Badge, see Badge - props | \nBadgeProps | \n- | \n
url | \nLink | \nstring | \n- | \n
to | \nThe target route should navigate to when clicked on, same as the to prop of Vue Router | \nstring | object | \n- | \n
replace | \nIf true, the navigation will not leave a history record | \nboolean | \nfalse | \n
Name | \nDescription | \nSlotProps | \n
---|---|---|
icon | \nCustom icon | \nactive: boolean | \n
The component exports the following type definitions:
\nimport type { TabbarProps, TabbarItemProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-tabbar-height | \n50px | \n- | \n
--van-tabbar-z-index | \n1 | \n- | \n
--van-tabbar-background | \nvar(--van-background-2) | \n- | \n
--van-tabbar-item-font-size | \nvar(--van-font-size-sm) | \n- | \n
--van-tabbar-item-text-color | \nvar(--van-text-color) | \n- | \n
--van-tabbar-item-active-color | \nvar(--van-primary-color) | \n- | \n
--van-tabbar-item-active-background | \nvar(--van-background-2) | \n- | \n
--van-tabbar-item-line-height | \n1 | \n- | \n
--van-tabbar-item-icon-size | \n22px | \n- | \n
--van-tabbar-item-icon-margin-bottom | \nvar(--van-padding-base) | \n- | \n