/*! For license information please see 9345.210bd0b9.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["9345"],{57672:function(t,n,s){"use strict";s.r(n);var a=s("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
Provide navigation function for the page, often used at the top of the page.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { NavBar } from 'vant';\n\nconst app = createApp();\napp.use(NavBar);\n
\n<van-nav-bar title="Title" />\n
\n<van-nav-bar\n title="Title"\n left-text="Back"\n left-arrow\n @click-left="onClickLeft"\n/>\n
\nexport default {\n setup() {\n const onClickLeft = () => history.back();\n return {\n onClickLeft,\n };\n },\n};\n
\n<van-nav-bar\n title="Title"\n left-text="Back"\n right-text="Button"\n left-arrow\n @click-left="onClickLeft"\n @click-right="onClickRight"\n/>\n
\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const onClickLeft = () => history.back();\n const onClickRight = () => showToast('Button');\n return {\n onClickLeft,\n onClickRight,\n };\n },\n};\n
\n<van-nav-bar title="Title" left-text="Back" left-arrow>\n <template #right>\n <van-icon name="search" />\n </template>\n</van-nav-bar>\n
\nUse the left-disabled
or right-disabled
props to disable the buttons on either side. The prop reduces the opacity of the button and makes it unclickable.
<van-nav-bar\n title="Title"\n left-text="Back"\n right-text="Button"\n left-arrow\n left-disabled\n right-disabled\n/>\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
title | \nTitle | \nstring | \n\'\' | \n
left-text | \nLeft Text | \nstring | \n\'\' | \n
right-text | \nRight Text | \nstring | \n\'\' | \n
left-disabled v4.6.8 | \nWhether to disable the left button, decrease opacity and make it unclickable | \nboolean | \nfalse | \n
right-disabled v4.6.8 | \nWhether to disable the right button, decrease opacity and make it unclickable | \nboolean | \nfalse | \n
left-arrow | \nWhether to show left arrow | \nboolean | \nfalse | \n
border | \nWhether to show bottom border | \nboolean | \ntrue | \n
fixed | \nWhether to fixed top | \nboolean | \nfalse | \n
placeholder | \nWhether to generate a placeholder element when fixed | \nboolean | \nfalse | \n
z-index | \nZ-index | \nnumber | string | \n1 | \n
safe-area-inset-top | \nWhether to enable top safe area adaptation | \nboolean | \nfalse | \n
clickable | \nWhether to show click feedback when the left or right content is clicked | \nboolean | \ntrue | \n
Name | \nDescription | \n
---|---|
title | \nCustom title | \n
left | \nCustom left side content | \n
right | \nCustom right side content | \n
Event | \nDescription | \nArguments | \n
---|---|---|
click-left | \nEmitted when the left button is clicked | \nevent: MouseEvent | \n
click-right | \nEmitted when the right button is clicked | \nevent: MouseEvent | \n
The component exports the following type definitions:
\nimport type { NavBarProps } 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-nav-bar-height | \n46px | \n- | \n
--van-nav-bar-background | \nvar(--van-background-2) | \n- | \n
--van-nav-bar-arrow-size | \n16px | \n- | \n
--van-nav-bar-icon-color | \nvar(--van-primary-color) | \n- | \n
--van-nav-bar-text-color | \nvar(--van-primary-color) | \n- | \n
--van-nav-bar-title-font-size | \nvar(--van-font-size-lg) | \n- | \n
--van-nav-bar-title-text-color | \nvar(--van-text-color) | \n- | \n
--van-nav-bar-z-index | \n1 | \n- | \n