mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
/*! For license information please see 6535.1dcfe2af.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["6535"],{36533: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:'<h1>Tag \u6807\u7B7E</h1>\n<div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>\u7528\u4E8E\u6807\u8BB0\u5173\u952E\u8BCD\u548C\u6982\u62EC\u4E3B\u8981\u5185\u5BB9\u3002</p>\n</div><div class="van-doc-card"><h3 id="yin-ru" tabindex="-1">\u5F15\u5165</h3>\n<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>\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_">Tag</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_">Tag</span>);\n</code></pre>\n</div><h2 id="dai-ma-yan-shi" tabindex="-1">\u4EE3\u7801\u6F14\u793A</h2>\n<div class="van-doc-card"><h3 id="ji-chu-yong-fa" tabindex="-1">\u57FA\u7840\u7528\u6CD5</h3>\n<p>\u901A\u8FC7 <code>type</code> \u5C5E\u6027\u63A7\u5236\u6807\u7B7E\u989C\u8272\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"success"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"danger"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"warning"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="kong-xin-yang-shi" tabindex="-1">\u7A7A\u5FC3\u6837\u5F0F</h3>\n<p>\u8BBE\u7F6E <code>plain</code> \u5C5E\u6027\u8BBE\u7F6E\u4E3A\u7A7A\u5FC3\u6837\u5F0F\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">plain</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="yuan-jiao-yang-shi" tabindex="-1">\u5706\u89D2\u6837\u5F0F</h3>\n<p>\u901A\u8FC7 <code>round</code> \u8BBE\u7F6E\u4E3A\u5706\u89D2\u6837\u5F0F\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">round</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="biao-ji-yang-shi" tabindex="-1">\u6807\u8BB0\u6837\u5F0F</h3>\n<p>\u901A\u8FC7 <code>mark</code> \u8BBE\u7F6E\u4E3A\u6807\u8BB0\u6837\u5F0F(\u534A\u5706\u89D2)\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">mark</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="ke-guan-bi-biao-qian" tabindex="-1">\u53EF\u5173\u95ED\u6807\u7B7E</h3>\n<p>\u6DFB\u52A0 <code>closeable</code> \u5C5E\u6027\u8868\u793A\u6807\u7B7E\u662F\u53EF\u5173\u95ED\u7684\uFF0C\u5173\u95ED\u6807\u7B7E\u65F6\u4F1A\u89E6\u53D1 <code>close</code> \u4E8B\u4EF6\uFF0C\u5728 <code>close</code> \u4E8B\u4EF6\u4E2D\u53EF\u4EE5\u6267\u884C\u9690\u85CF\u6807\u7B7E\u7684\u903B\u8F91\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">:show</span>=<span class="hljs-string">"show"</span> <span class="hljs-attr">closeable</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"medium"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span> @<span class="hljs-attr">close</span>=<span class="hljs-string">"close"</span>></span>\n \u6807\u7B7E\n<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</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> show = <span class="hljs-title function_">ref</span>(<span class="hljs-literal">true</span>);\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">close</span> = (<span class="hljs-params"></span>) => {\n show.<span class="hljs-property">value</span> = <span class="hljs-literal">false</span>;\n };\n\n <span class="hljs-keyword">return</span> {\n show,\n close,\n };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="biao-qian-da-xiao" tabindex="-1">\u6807\u7B7E\u5927\u5C0F</h3>\n<p>\u901A\u8FC7 <code>size</code> \u5C5E\u6027\u8C03\u6574\u6807\u7B7E\u5927\u5C0F\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"medium"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"large"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zi-ding-yi-yan-se" tabindex="-1">\u81EA\u5B9A\u4E49\u989C\u8272</h3>\n<p>\u901A\u8FC7 <code>color</code> \u548C <code>text-color</code> \u5C5E\u6027\u8BBE\u7F6E\u6807\u7B7E\u989C\u8272\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">color</span>=<span class="hljs-string">"#7232dd"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">color</span>=<span class="hljs-string">"#ffe1e1"</span> <span class="hljs-attr">text-color</span>=<span class="hljs-string">"#ad0000"</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">color</span>=<span class="hljs-string">"#7232dd"</span> <span class="hljs-attr">plain</span>></span>\u6807\u7B7E<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></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>\u53C2\u6570</th>\n<th>\u8BF4\u660E</th>\n<th>\u7C7B\u578B</th>\n<th>\u9ED8\u8BA4\u503C</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>type</td>\n<td>\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A <code>primary</code> <code>success</code> <code>danger</code> <code>warning</code></td>\n<td><em>string</em></td>\n<td><code>default</code></td>\n</tr>\n<tr>\n<td>size</td>\n<td>\u5927\u5C0F, \u53EF\u9009\u503C\u4E3A <code>large</code> <code>medium</code></td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>color</td>\n<td>\u6807\u7B7E\u989C\u8272</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>show</td>\n<td>\u662F\u5426\u5C55\u793A\u6807\u7B7E</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>plain</td>\n<td>\u662F\u5426\u4E3A\u7A7A\u5FC3\u6837\u5F0F</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>round</td>\n<td>\u662F\u5426\u4E3A\u5706\u89D2\u6837\u5F0F</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>mark</td>\n<td>\u662F\u5426\u4E3A\u6807\u8BB0\u6837\u5F0F</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>text-color</td>\n<td>\u6587\u672C\u989C\u8272\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E <code>color</code> \u5C5E\u6027</td>\n<td><em>string</em></td>\n<td><code>white</code></td>\n</tr>\n<tr>\n<td>closeable</td>\n<td>\u662F\u5426\u4E3A\u53EF\u5173\u95ED\u6807\u7B7E</td>\n<td><em>boolean</em></td>\n<td><code>false</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>\u540D\u79F0</th>\n<th>\u8BF4\u660E</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>default</td>\n<td>\u6807\u7B7E\u663E\u793A\u5185\u5BB9</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>\u4E8B\u4EF6\u540D</th>\n<th>\u8BF4\u660E</th>\n<th>\u56DE\u8C03\u53C2\u6570</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>click</td>\n<td>\u70B9\u51FB\u65F6\u89E6\u53D1</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n<tr>\n<td>close</td>\n<td>\u5173\u95ED\u6807\u7B7E\u65F6\u89E6\u53D1</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3>\n<p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">TagSize</span>, <span class="hljs-title class_">TagType</span>, <span class="hljs-title class_">TagProps</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n</code></pre>\n</div><h2 id="zhu-ti-ding-zhi" tabindex="-1">\u4E3B\u9898\u5B9A\u5236</h2>\n<div class="van-doc-card"><h3 id="yang-shi-bian-liang" tabindex="-1">\u6837\u5F0F\u53D8\u91CF</h3>\n<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>\n<table>\n<thead>\n<tr>\n<th>\u540D\u79F0</th>\n<th>\u9ED8\u8BA4\u503C</th>\n<th>\u63CF\u8FF0</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>--van-tag-padding</td>\n<td><em>0 var(--van-padding-base)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-text-color</td>\n<td><em>var(--van-white)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-font-size</td>\n<td><em>var(--van-font-size-sm)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-radius</td>\n<td><em>2px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-line-height</td>\n<td><em>16px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-medium-padding</td>\n<td><em>2px 6px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-large-padding</td>\n<td><em>var(--van-padding-base) var(--van-padding-xs)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-large-radius</td>\n<td><em>var(--van-radius-md)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-large-font-size</td>\n<td><em>var(--van-font-size-md)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-round-radius</td>\n<td><em>var(--van-radius-max)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-danger-color</td>\n<td><em>var(--van-danger-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-primary-color</td>\n<td><em>var(--van-primary-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-success-color</td>\n<td><em>var(--van-success-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-warning-color</td>\n<td><em>var(--van-warning-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-default-color</td>\n<td><em>var(--van-gray-6)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-tag-plain-background</td>\n<td><em>var(--van-background-2)</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,l))}}}]); |