mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
50 lines
13 KiB
JavaScript
50 lines
13 KiB
JavaScript
import{o as a,a as t,y as n}from"./vue-libs.b44bc779.js";const d={class:"van-doc-markdown-body"},e=n(`<h1>Sidebar \u4FA7\u8FB9\u5BFC\u822A</h1><div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3><p>\u5782\u76F4\u5C55\u793A\u7684\u5BFC\u822A\u680F\uFF0C\u7528\u4E8E\u5728\u4E0D\u540C\u7684\u5185\u5BB9\u533A\u57DF\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002</p></div><div class="van-doc-card"><h3 id="yin-ru" tabindex="-1">\u5F15\u5165</h3><p>\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003<a href="#/zh-CN/advanced-usage#zu-jian-zhu-ce" target="_blank">\u7EC4\u4EF6\u6CE8\u518C</a>\u3002</p><pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;
|
|
<span class="hljs-keyword">import</span> { <span class="hljs-title class_">Sidebar</span>, <span class="hljs-title class_">SidebarItem</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
|
|
<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>();
|
|
app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">Sidebar</span>);
|
|
app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">SidebarItem</span>);
|
|
</code></pre></div><h2 id="dai-ma-yan-shi" tabindex="-1">\u4EE3\u7801\u6F14\u793A</h2><div class="van-doc-card"><h3 id="ji-chu-yong-fa" tabindex="-1">\u57FA\u7840\u7528\u6CD5</h3><p>\u901A\u8FC7 <code>v-model</code> \u7ED1\u5B9A\u5F53\u524D\u9009\u4E2D\u9879\u7684\u7D22\u5F15\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-sidebar</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"active"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-sidebar</span>></span>
|
|
</code></pre><pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;
|
|
|
|
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
|
|
<span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
|
|
<span class="hljs-keyword">const</span> active = <span class="hljs-title function_">ref</span>(<span class="hljs-number">0</span>);
|
|
<span class="hljs-keyword">return</span> { active };
|
|
},
|
|
};
|
|
</code></pre></div><div class="van-doc-card"><h3 id="hui-biao-ti-shi" tabindex="-1">\u5FBD\u6807\u63D0\u793A</h3><p>\u8BBE\u7F6E <code>dot</code> \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u53F3\u4E0A\u89D2\u5C55\u793A\u4E00\u4E2A\u5C0F\u7EA2\u70B9\uFF1B\u8BBE\u7F6E <code>badge</code> \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u53F3\u4E0A\u89D2\u5C55\u793A\u76F8\u5E94\u7684\u5FBD\u6807\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-sidebar</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"active"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> <span class="hljs-attr">dot</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> <span class="hljs-attr">badge</span>=<span class="hljs-string">"5"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> <span class="hljs-attr">badge</span>=<span class="hljs-string">"20"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-sidebar</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="jin-yong-xuan-xiang" tabindex="-1">\u7981\u7528\u9009\u9879</h3><p>\u901A\u8FC7 <code>disabled</code> \u5C5E\u6027\u7981\u7528\u9009\u9879\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-sidebar</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"active"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> <span class="hljs-attr">disabled</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D\u79F0"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-sidebar</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="jian-ting-qie-huan-shi-jian" tabindex="-1">\u76D1\u542C\u5207\u6362\u4E8B\u4EF6</h3><p>\u8BBE\u7F6E <code>change</code> \u65B9\u6CD5\u6765\u76D1\u542C\u5207\u6362\u5BFC\u822A\u9879\u65F6\u7684\u4E8B\u4EF6\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-sidebar</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"active"</span> @<span class="hljs-attr">change</span>=<span class="hljs-string">"onChange"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D 1"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D 2"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-sidebar-item</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u7B7E\u540D 3"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-sidebar</span>></span>
|
|
</code></pre><pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;
|
|
<span class="hljs-keyword">import</span> { <span class="hljs-title class_">Toast</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
|
|
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
|
|
<span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
|
|
<span class="hljs-keyword">const</span> active = <span class="hljs-title function_">ref</span>(<span class="hljs-number">0</span>);
|
|
<span class="hljs-keyword">const</span> <span class="hljs-title function_">onChange</span> = (<span class="hljs-params">index</span>) => <span class="hljs-title class_">Toast</span>(<span class="hljs-string">\`\u6807\u7B7E\u540D <span class="hljs-subst">\${index + <span class="hljs-number">1</span>}</span>\`</span>);
|
|
<span class="hljs-keyword">return</span> {
|
|
active,
|
|
onChange,
|
|
};
|
|
},
|
|
};
|
|
</code></pre></div><h2 id="api" tabindex="-1">API</h2><div class="van-doc-card"><h3 id="sidebar-props" tabindex="-1">Sidebar Props</h3><table><thead><tr><th>\u53C2\u6570</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th><th>\u9ED8\u8BA4\u503C</th></tr></thead><tbody><tr><td>v-model</td><td>\u5F53\u524D\u5BFC\u822A\u9879\u7684\u7D22\u5F15</td><td><em>number | string</em></td><td><code>0</code></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="sidebar-events" tabindex="-1">Sidebar Events</h3><table><thead><tr><th>\u4E8B\u4EF6\u540D</th><th>\u8BF4\u660E</th><th>\u56DE\u8C03\u53C2\u6570</th></tr></thead><tbody><tr><td>change</td><td>\u5207\u6362\u5BFC\u822A\u9879\u65F6\u89E6\u53D1</td><td><em>index: number</em></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="sidebaritem-props" tabindex="-1">SidebarItem Props</h3><table><thead><tr><th>\u53C2\u6570</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th><th>\u9ED8\u8BA4\u503C</th></tr></thead><tbody><tr><td>title</td><td>\u5185\u5BB9</td><td><em>string</em></td><td><code>''</code></td></tr><tr><td>dot</td><td>\u662F\u5426\u663E\u793A\u53F3\u4E0A\u89D2\u5C0F\u7EA2\u70B9</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>badge</td><td>\u56FE\u6807\u53F3\u4E0A\u89D2\u5FBD\u6807\u7684\u5185\u5BB9</td><td><em>number | string</em></td><td>-</td></tr><tr><td>badge-props <code>v3.2.8</code></td><td>\u81EA\u5B9A\u4E49\u5FBD\u6807\u7684\u5C5E\u6027\uFF0C\u4F20\u5165\u7684\u5BF9\u8C61\u4F1A\u88AB\u900F\u4F20\u7ED9 <a href="#/zh-CN/badge#props" target="_blank">Badge \u7EC4\u4EF6\u7684 props</a></td><td><em>BadgeProps</em></td><td>-</td></tr><tr><td>disabled</td><td>\u662F\u5426\u7981\u7528\u8BE5\u9879</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>url</td><td>\u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u94FE\u63A5\u5730\u5740</td><td><em>string</em></td><td>-</td></tr><tr><td>to</td><td>\u70B9\u51FB\u540E\u8DF3\u8F6C\u7684\u76EE\u6807\u8DEF\u7531\u5BF9\u8C61\uFF0C\u7B49\u540C\u4E8E vue-router \u7684 <a href="https://router.vuejs.org/zh/api/#to" target="_blank">to \u5C5E\u6027</a></td><td><em>string | object</em></td><td>-</td></tr><tr><td>replace</td><td>\u662F\u5426\u5728\u8DF3\u8F6C\u65F6\u66FF\u6362\u5F53\u524D\u9875\u9762\u5386\u53F2</td><td><em>boolean</em></td><td><code>false</code></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="sidebaritem-events" tabindex="-1">SidebarItem Events</h3><table><thead><tr><th>\u4E8B\u4EF6\u540D</th><th>\u8BF4\u660E</th><th>\u56DE\u8C03\u53C2\u6570</th></tr></thead><tbody><tr><td>click</td><td>\u70B9\u51FB\u65F6\u89E6\u53D1</td><td><em>index: number</em></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="sidebaritem-slots" tabindex="-1">SidebarItem Slots</h3><table><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td>title</td><td>\u81EA\u5B9A\u4E49\u6807\u9898</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3><p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</p><pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">SidebarProps</span>, <span class="hljs-title class_">SidebarItemProps</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
</code></pre></div><h2 id="zhu-ti-ding-zhi" tabindex="-1">\u4E3B\u9898\u5B9A\u5236</h2><div class="van-doc-card"><h3 id="yang-shi-bian-liang" tabindex="-1">\u6837\u5F0F\u53D8\u91CF</h3><p>\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 <a href="#/zh-CN/config-provider" target="_blank">ConfigProvider \u7EC4\u4EF6</a>\u3002</p><table><thead><tr><th>\u540D\u79F0</th><th>\u9ED8\u8BA4\u503C</th><th>\u63CF\u8FF0</th></tr></thead><tbody><tr><td>--van-sidebar-width</td><td><em>80px</em></td><td>-</td></tr><tr><td>--van-sidebar-font-size</td><td><em>var(--van-font-size-md)</em></td><td>-</td></tr><tr><td>--van-sidebar-line-height</td><td><em>var(--van-line-height-md)</em></td><td>-</td></tr><tr><td>--van-sidebar-text-color</td><td><em>var(--van-text-color)</em></td><td>-</td></tr><tr><td>--van-sidebar-disabled-text-color</td><td><em>var(--van-text-color-3)</em></td><td>-</td></tr><tr><td>--van-sidebar-padding</td><td><em>20px var(--van-padding-sm)</em></td><td>-</td></tr><tr><td>--van-sidebar-active-color</td><td><em>var(--van-active-color)</em></td><td>-</td></tr><tr><td>--van-sidebar-background-color</td><td><em>var(--van-background-color)</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-font-weight</td><td><em>var(--van-font-weight-bold)</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-text-color</td><td><em>var(--van-text-color)</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-border-width</td><td><em>4px</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-border-height</td><td><em>16px</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-border-color</td><td><em>var(--van-danger-color)</em></td><td>-</td></tr><tr><td>--van-sidebar-selected-background-color</td><td><em>var(--van-background-color-light)</em></td><td>-</td></tr></tbody></table></div>`,17),l=[e],o={__name:"README.zh-CN",setup(p,{expose:s}){return s({frontmatter:{}}),(c,i)=>(a(),t("div",d,l))}};export{o as default};
|