/*! For license information please see 2428.508082db.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["2428"],{92291: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:'

Tabbar \u6807\u7B7E\u680F

\n

\u4ECB\u7ECD

\n

\u5E95\u90E8\u5BFC\u822A\u680F\uFF0C\u7528\u4E8E\u5728\u4E0D\u540C\u9875\u9762\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002

\n

\u5F15\u5165

\n

\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002

\n
import { createApp } from 'vue';\nimport { Tabbar, TabbarItem } from 'vant';\n\nconst app = createApp();\napp.use(Tabbar);\napp.use(TabbarItem);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

v-model \u9ED8\u8BA4\u7ED1\u5B9A\u9009\u4E2D\u6807\u7B7E\u7684\u7D22\u5F15\u503C\uFF0C\u901A\u8FC7\u4FEE\u6539 v-model \u5373\u53EF\u5207\u6362\u9009\u4E2D\u7684\u6807\u7B7E\u3002

\n
<van-tabbar v-model="active">\n  <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="search">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="friends-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const active = ref(0);\n    return { active };\n  },\n};\n
\n

\u901A\u8FC7\u540D\u79F0\u5339\u914D

\n

\u5728\u6807\u7B7E\u6307\u5B9A name \u5C5E\u6027\u7684\u60C5\u51B5\u4E0B\uFF0Cv-model \u7684\u503C\u4E3A\u5F53\u524D\u6807\u7B7E\u7684 name\u3002

\n
<van-tabbar v-model="active">\n  <van-tabbar-item name="home" icon="home-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item name="search" icon="search">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item name="friends" icon="friends-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item name="setting" icon="setting-o">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const active = ref('home');\n    return { active };\n  },\n};\n
\n

\u5FBD\u6807\u63D0\u793A

\n

\u8BBE\u7F6E dot \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\uFF1B\u8BBE\u7F6E badge \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u56FE\u6807\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002

\n
<van-tabbar v-model="active">\n  <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="search" dot>\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="friends-o" badge="5">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="setting-o" badge="20">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n

\u81EA\u5B9A\u4E49\u56FE\u6807

\n

\u901A\u8FC7 icon \u63D2\u69FD\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u53EF\u4EE5\u901A\u8FC7 slot-scope \u5224\u65AD\u6807\u7B7E\u662F\u5426\u9009\u4E2D\u3002

\n
<van-tabbar v-model="active">\n  <van-tabbar-item badge="3">\n    <span>\u81EA\u5B9A\u4E49</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">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n
import { 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

\u81EA\u5B9A\u4E49\u989C\u8272

\n

\u901A\u8FC7 active-color \u5C5E\u6027\u8BBE\u7F6E\u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272\uFF0C\u901A\u8FC7 inactive-color \u5C5E\u6027\u8BBE\u7F6E\u672A\u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272\u3002

\n
<van-tabbar v-model="active" active-color="#ee0a24">\n  <van-tabbar-item icon="home-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="search">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="friends-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item icon="setting-o">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n

\u76D1\u542C\u5207\u6362\u4E8B\u4EF6

\n

\u901A\u8FC7 change \u4E8B\u4EF6\u6765\u76D1\u542C\u9009\u4E2D\u6807\u7B7E\u7684\u53D8\u5316\u3002

\n
<van-tabbar v-model="active" @change="onChange">\n  <van-tabbar-item icon="home-o">\u6807\u7B7E 1</van-tabbar-item>\n  <van-tabbar-item icon="search">\u6807\u7B7E 2</van-tabbar-item>\n  <van-tabbar-item icon="friends-o">\u6807\u7B7E 3</van-tabbar-item>\n  <van-tabbar-item icon="setting-o">\u6807\u7B7E 4</van-tabbar-item>\n</van-tabbar>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const active = ref(0);\n    const onChange = (index) => showToast(`\u6807\u7B7E ${index}`);\n    return {\n      icon,\n      onChange,\n    };\n  },\n};\n
\n

\u8DEF\u7531\u6A21\u5F0F

\n

\u6807\u7B7E\u680F\u652F\u6301\u8DEF\u7531\u6A21\u5F0F\uFF0C\u7528\u4E8E\u642D\u914D Vue Router \u4F7F\u7528\u3002\u8DEF\u7531\u6A21\u5F0F\u4E0B\u4F1A\u5339\u914D\u9875\u9762\u8DEF\u5F84\u548C\u6807\u7B7E\u7684 to \u5C5E\u6027\uFF0C\u5E76\u81EA\u52A8\u9009\u4E2D\u5BF9\u5E94\u7684\u6807\u7B7E\u3002

\n
<router-view />\n\n<van-tabbar route>\n  <van-tabbar-item replace to="/home" icon="home-o">\u6807\u7B7E</van-tabbar-item>\n  <van-tabbar-item replace to="/search" icon="search">\u6807\u7B7E</van-tabbar-item>\n</van-tabbar>\n
\n

API

\n

Tabbar Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
v-model\u5F53\u524D\u9009\u4E2D\u6807\u7B7E\u7684\u540D\u79F0\u6216\u7D22\u5F15\u503Cnumber | string0
fixed\u662F\u5426\u56FA\u5B9A\u5728\u5E95\u90E8booleantrue
border\u662F\u5426\u663E\u793A\u5916\u8FB9\u6846booleantrue
z-index\u5143\u7D20 z-indexnumber | string1
active-color\u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272string#1989fa
inactive-color\u672A\u9009\u4E2D\u6807\u7B7E\u7684\u989C\u8272string#7d7e80
route\u662F\u5426\u5F00\u542F\u8DEF\u7531\u6A21\u5F0Fbooleanfalse
placeholder\u56FA\u5B9A\u5728\u5E95\u90E8\u65F6\uFF0C\u662F\u5426\u5728\u6807\u7B7E\u4F4D\u7F6E\u751F\u6210\u4E00\u4E2A\u7B49\u9AD8\u7684\u5360\u4F4D\u5143\u7D20booleanfalse
safe-area-inset-bottom\u662F\u5426\u5F00\u542F\u5E95\u90E8\u5B89\u5168\u533A\u9002\u914D\uFF0C\u8BBE\u7F6E fixed \u65F6\u9ED8\u8BA4\u5F00\u542Fbooleanfalse
before-change\u5207\u6362\u6807\u7B7E\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE false \u53EF\u963B\u6B62\u5207\u6362\uFF0C\u652F\u6301\u8FD4\u56DE Promise(name: number | string) => boolean | Promise<boolean>-
\n

Tabbar Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
change\u5207\u6362\u6807\u7B7E\u65F6\u89E6\u53D1active: number | string
\n

TabbarItem Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
name\u6807\u7B7E\u540D\u79F0\uFF0C\u4F5C\u4E3A\u5339\u914D\u7684\u6807\u8BC6\u7B26number | string\u5F53\u524D\u6807\u7B7E\u7684\u7D22\u5F15\u503C
icon\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027string-
icon-prefix\u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027stringvan-icon
dot\u662F\u5426\u663E\u793A\u56FE\u6807\u53F3\u4E0A\u89D2\u5C0F\u7EA2\u70B9booleanfalse
badge\u56FE\u6807\u53F3\u4E0A\u89D2\u5FBD\u6807\u7684\u5185\u5BB9number | string-
badge-props\u81EA\u5B9A\u4E49\u5FBD\u6807\u7684\u5C5E\u6027\uFF0C\u4F20\u5165\u7684\u5BF9\u8C61\u4F1A\u88AB\u900F\u4F20\u7ED9 Badge \u7EC4\u4EF6\u7684 propsBadgeProps-
url\u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740string-
to\u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u76EE\u6807\u8DEF\u7531\u5BF9\u8C61\uFF0C\u7B49\u540C\u4E8E Vue Router \u7684 to \u5C5E\u6027string | object-
replace\u662F\u5426\u5728\u8DF3\u8F6C\u65F6\u66FF\u6362\u5F53\u524D\u9875\u9762\u5386\u53F2booleanfalse
\n

TabbarItem Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u53C2\u6570
icon\u81EA\u5B9A\u4E49\u56FE\u6807active: boolean
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type { TabbarProps, TabbarItemProps } from 'vant';\n
\n

\u4E3B\u9898\u5B9A\u5236

\n

\u6837\u5F0F\u53D8\u91CF

\n

\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-tabbar-height50px-
--van-tabbar-z-index1-
--van-tabbar-backgroundvar(--van-background-2)-
--van-tabbar-item-font-sizevar(--van-font-size-sm)-
--van-tabbar-item-text-colorvar(--van-text-color)-
--van-tabbar-item-active-colorvar(--van-primary-color)-
--van-tabbar-item-active-backgroundvar(--van-background-2)-
--van-tabbar-item-line-height1-
--van-tabbar-item-icon-size22px-
--van-tabbar-item-icon-margin-bottomvar(--van-padding-base)-
\n
'},null,8,l))}}}]);