mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
/*! 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:'<h1>NavBar</h1>\n<div class="van-doc-card"><h3 id="intro" tabindex="-1">Intro</h3>\n<p>Provide navigation function for the page, often used at the top of the page.</p>\n</div><div class="van-doc-card"><h3 id="install" tabindex="-1">Install</h3>\n<p>Register component globally via <code>app.use</code>, refer to <a href="#/en-US/advanced-usage#zu-jian-zhu-ce" target="_blank">Component Registration</a> for more registration ways.</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;\n<span class="hljs-keyword">import</span> { <span class="hljs-title class_">NavBar</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>();\napp.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">NavBar</span>);\n</code></pre>\n</div><h2 id="usage" tabindex="-1">Usage</h2>\n<div class="van-doc-card"><h3 id="basic-usage" tabindex="-1">Basic Usage</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-nav-bar</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span> /></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="back" tabindex="-1">Back</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-nav-bar</span>\n <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span>\n <span class="hljs-attr">left-text</span>=<span class="hljs-string">"Back"</span>\n <span class="hljs-attr">left-arrow</span>\n @<span class="hljs-attr">click-left</span>=<span class="hljs-string">"onClickLeft"</span>\n/></span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">onClickLeft</span> = (<span class="hljs-params"></span>) => history.<span class="hljs-title function_">back</span>();\n <span class="hljs-keyword">return</span> {\n onClickLeft,\n };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="right-button" tabindex="-1">Right Button</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-nav-bar</span>\n <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span>\n <span class="hljs-attr">left-text</span>=<span class="hljs-string">"Back"</span>\n <span class="hljs-attr">right-text</span>=<span class="hljs-string">"Button"</span>\n <span class="hljs-attr">left-arrow</span>\n @<span class="hljs-attr">click-left</span>=<span class="hljs-string">"onClickLeft"</span>\n @<span class="hljs-attr">click-right</span>=<span class="hljs-string">"onClickRight"</span>\n/></span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showToast } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">onClickLeft</span> = (<span class="hljs-params"></span>) => history.<span class="hljs-title function_">back</span>();\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">onClickRight</span> = (<span class="hljs-params"></span>) => <span class="hljs-title function_">showToast</span>(<span class="hljs-string">'Button'</span>);\n <span class="hljs-keyword">return</span> {\n onClickLeft,\n onClickRight,\n };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="use-slot" tabindex="-1">Use Slot</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-nav-bar</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span> <span class="hljs-attr">left-text</span>=<span class="hljs-string">"Back"</span> <span class="hljs-attr">left-arrow</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">template</span> #<span class="hljs-attr">right</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"search"</span> /></span>\n <span class="hljs-tag"></<span class="hljs-name">template</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-nav-bar</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="disable-button" tabindex="-1">Disable Button</h3>\n<p>Use the <code>left-disabled</code> or <code>right-disabled</code> props to disable the buttons on either side. The prop reduces the opacity of the button and makes it unclickable.</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-nav-bar</span>\n <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span>\n <span class="hljs-attr">left-text</span>=<span class="hljs-string">"Back"</span>\n <span class="hljs-attr">right-text</span>=<span class="hljs-string">"Button"</span>\n <span class="hljs-attr">left-arrow</span>\n <span class="hljs-attr">left-disabled</span>\n <span class="hljs-attr">right-disabled</span>\n/></span>\n</code></pre>\n</div><h2 id="api" tabindex="-1">API</h2>\n<div class="van-doc-card"><h3 id="props" tabindex="-1">Props</h3>\n<table>\n<thead>\n<tr>\n<th>Attribute</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>title</td>\n<td>Title</td>\n<td><em>string</em></td>\n<td><code>\'\'</code></td>\n</tr>\n<tr>\n<td>left-text</td>\n<td>Left Text</td>\n<td><em>string</em></td>\n<td><code>\'\'</code></td>\n</tr>\n<tr>\n<td>right-text</td>\n<td>Right Text</td>\n<td><em>string</em></td>\n<td><code>\'\'</code></td>\n</tr>\n<tr>\n<td>left-disabled <code>v4.6.8</code></td>\n<td>Whether to disable the left button, decrease opacity and make it unclickable</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>right-disabled <code>v4.6.8</code></td>\n<td>Whether to disable the right button, decrease opacity and make it unclickable</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>left-arrow</td>\n<td>Whether to show left arrow</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>border</td>\n<td>Whether to show bottom border</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>fixed</td>\n<td>Whether to fixed top</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>placeholder</td>\n<td>Whether to generate a placeholder element when fixed</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>z-index</td>\n<td>Z-index</td>\n<td><em>number | string</em></td>\n<td><code>1</code></td>\n</tr>\n<tr>\n<td>safe-area-inset-top</td>\n<td>Whether to enable top safe area adaptation</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>clickable</td>\n<td>Whether to show click feedback when the left or right content is clicked</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="slots" tabindex="-1">Slots</h3>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>title</td>\n<td>Custom title</td>\n</tr>\n<tr>\n<td>left</td>\n<td>Custom left side content</td>\n</tr>\n<tr>\n<td>right</td>\n<td>Custom right side content</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="events" tabindex="-1">Events</h3>\n<table>\n<thead>\n<tr>\n<th>Event</th>\n<th>Description</th>\n<th>Arguments</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>click-left</td>\n<td>Emitted when the left button is clicked</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n<tr>\n<td>click-right</td>\n<td>Emitted when the right button is clicked</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="types" tabindex="-1">Types</h3>\n<p>The component exports the following type definitions:</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">NavBarProps</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n</code></pre>\n</div><h2 id="theming" tabindex="-1">Theming</h2>\n<div class="van-doc-card"><h3 id="css-variables" tabindex="-1">CSS Variables</h3>\n<p>The component provides the following CSS variables, which can be used to customize styles. Please refer to <a href="#/en-US/config-provider" target="_blank">ConfigProvider component</a>.</p>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Default Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>--van-nav-bar-height</td>\n<td><em>46px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-background</td>\n<td><em>var(--van-background-2)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-arrow-size</td>\n<td><em>16px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-icon-color</td>\n<td><em>var(--van-primary-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-text-color</td>\n<td><em>var(--van-primary-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-title-font-size</td>\n<td><em>var(--van-font-size-lg)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-title-text-color</td>\n<td><em>var(--van-text-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-nav-bar-z-index</td>\n<td><em>1</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,e))}}}]); |