mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
28 KiB
JavaScript
2 lines
28 KiB
JavaScript
/*! For license information please see 2493.8a856b71.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["2493"],{8596:function(n,t,s){"use strict";s.r(t);var d=s("80681");let a=["innerHTML"];t.default={setup:()=>({html:""}),render:()=>((0,d.wg)(),(0,d.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>Dialog \u5F39\u51FA\u6846</h1>\n<div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>\u5F39\u51FA\u6A21\u6001\u6846\uFF0C\u5E38\u7528\u4E8E\u6D88\u606F\u63D0\u793A\u3001\u6D88\u606F\u786E\u8BA4\uFF0C\u6216\u5728\u5F53\u524D\u9875\u9762\u5185\u5B8C\u6210\u7279\u5B9A\u7684\u4EA4\u4E92\u64CD\u4F5C\u3002\u652F\u6301\u7EC4\u4EF6\u8C03\u7528\u548C\u51FD\u6570\u8C03\u7528\u4E24\u79CD\u65B9\u5F0F\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_">Dialog</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_">Dialog</span>);\n</code></pre>\n</div><div class="van-doc-card"><h3 id="han-shu-diao-yong" tabindex="-1">\u51FD\u6570\u8C03\u7528</h3>\n<p>\u4E3A\u4E86\u4FBF\u4E8E\u4F7F\u7528 <code>Dialog</code>\uFF0CVant \u63D0\u4F9B\u4E86\u4E00\u7CFB\u5217\u8F85\u52A9\u51FD\u6570\uFF0C\u901A\u8FC7\u8F85\u52A9\u51FD\u6570\u53EF\u4EE5\u5FEB\u901F\u5524\u8D77\u5168\u5C40\u7684\u5F39\u7A97\u7EC4\u4EF6\u3002</p>\n<p>\u6BD4\u5982\u4F7F\u7528 <code>showDialog</code> \u51FD\u6570\uFF0C\u8C03\u7528\u540E\u4F1A\u76F4\u63A5\u5728\u9875\u9762\u4E2D\u6E32\u67D3\u5BF9\u5E94\u7684\u5F39\u51FA\u6846\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-title function_">showDialog</span>({ <span class="hljs-attr">message</span>: <span class="hljs-string">'\u63D0\u793A'</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="xiao-xi-ti-shi" tabindex="-1">\u6D88\u606F\u63D0\u793A</h3>\n<p>\u7528\u4E8E\u63D0\u793A\u4E00\u4E9B\u6D88\u606F\uFF0C\u9ED8\u8BA4\u53EA\u5305\u542B\u4E00\u4E2A\u786E\u8BA4\u6309\u94AE\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-title function_">showDialog</span>({\n <span class="hljs-attr">title</span>: <span class="hljs-string">'\u6807\u9898'</span>,\n <span class="hljs-attr">message</span>: <span class="hljs-string">'\u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002'</span>,\n}).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on close</span>\n});\n\n<span class="hljs-title function_">showDialog</span>({\n <span class="hljs-attr">message</span>: <span class="hljs-string">'\u751F\u547D\u8FDC\u4E0D\u6B62\u8FDE\u8F74\u8F6C\u548C\u5FD9\u5230\u6781\u9650\uFF0C\u4EBA\u7C7B\u7684\u4F53\u9A8C\u8FDC\u6BD4\u8FD9\u8FBD\u9614\u3001\u4E30\u5BCC\u5F97\u591A\u3002'</span>,\n}).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on close</span>\n});\n</code></pre>\n</div><div class="van-doc-card"><h3 id="xiao-xi-que-ren" tabindex="-1">\u6D88\u606F\u786E\u8BA4</h3>\n<p>\u7528\u4E8E\u786E\u8BA4\u6D88\u606F\uFF0C\u9ED8\u8BA4\u5305\u542B\u786E\u8BA4\u548C\u53D6\u6D88\u6309\u94AE\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showConfirmDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-title function_">showConfirmDialog</span>({\n <span class="hljs-attr">title</span>: <span class="hljs-string">'\u6807\u9898'</span>,\n <span class="hljs-attr">message</span>:\n <span class="hljs-string">'\u5982\u679C\u89E3\u51B3\u65B9\u6CD5\u662F\u4E11\u964B\u7684\uFF0C\u90A3\u5C31\u80AF\u5B9A\u8FD8\u6709\u66F4\u597D\u7684\u89E3\u51B3\u65B9\u6CD5\uFF0C\u53EA\u662F\u8FD8\u6CA1\u6709\u53D1\u73B0\u800C\u5DF2\u3002'</span>,\n})\n .<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on confirm</span>\n })\n .<span class="hljs-title function_">catch</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on cancel</span>\n });\n</code></pre>\n</div><div class="van-doc-card"><h3 id="yuan-jiao-an-niu-feng-ge" tabindex="-1">\u5706\u89D2\u6309\u94AE\u98CE\u683C</h3>\n<p>\u5C06 theme \u9009\u9879\u8BBE\u7F6E\u4E3A <code>round-button</code> \u53EF\u4EE5\u5C55\u793A\u5706\u89D2\u6309\u94AE\u98CE\u683C\u7684\u5F39\u7A97\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-title function_">showDialog</span>({\n <span class="hljs-attr">title</span>: <span class="hljs-string">'\u6807\u9898'</span>,\n <span class="hljs-attr">message</span>: <span class="hljs-string">'\u4EE3\u7801\u662F\u5199\u51FA\u6765\u7ED9\u4EBA\u770B\u7684\uFF0C\u9644\u5E26\u80FD\u5728\u673A\u5668\u4E0A\u8FD0\u884C\u3002'</span>,\n <span class="hljs-attr">theme</span>: <span class="hljs-string">'round-button'</span>,\n}).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on close</span>\n});\n\n<span class="hljs-title function_">showDialog</span>({\n <span class="hljs-attr">message</span>: <span class="hljs-string">'\u751F\u547D\u8FDC\u4E0D\u6B62\u8FDE\u8F74\u8F6C\u548C\u5FD9\u5230\u6781\u9650\uFF0C\u4EBA\u7C7B\u7684\u4F53\u9A8C\u8FDC\u6BD4\u8FD9\u8FBD\u9614\u3001\u4E30\u5BCC\u5F97\u591A\u3002'</span>,\n <span class="hljs-attr">theme</span>: <span class="hljs-string">'round-button'</span>,\n}).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on close</span>\n});\n</code></pre>\n</div><div class="van-doc-card"><h3 id="yi-bu-guan-bi" tabindex="-1">\u5F02\u6B65\u5173\u95ED</h3>\n<p>\u901A\u8FC7 <code>beforeClose</code> \u5C5E\u6027\u53EF\u4EE5\u4F20\u5165\u4E00\u4E2A\u56DE\u8C03\u51FD\u6570\uFF0C\u5728\u5F39\u7A97\u5173\u95ED\u524D\u8FDB\u884C\u7279\u5B9A\u64CD\u4F5C\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showConfirmDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-keyword">const</span> <span class="hljs-title function_">beforeClose</span> = (<span class="hljs-params">action</span>) =>\n <span class="hljs-keyword">new</span> <span class="hljs-title class_">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve</span>) =></span> {\n <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// action !== 'confirm' \u62E6\u622A\u53D6\u6D88\u64CD\u4F5C</span>\n <span class="hljs-title function_">resolve</span>(action === <span class="hljs-string">'confirm'</span>);\n }, <span class="hljs-number">1000</span>);\n });\n\n<span class="hljs-title function_">showConfirmDialog</span>({\n <span class="hljs-attr">title</span>: <span class="hljs-string">'\u6807\u9898'</span>,\n <span class="hljs-attr">message</span>:\n <span class="hljs-string">'\u5982\u679C\u89E3\u51B3\u65B9\u6CD5\u662F\u4E11\u964B\u7684\uFF0C\u90A3\u5C31\u80AF\u5B9A\u8FD8\u6709\u66F4\u597D\u7684\u89E3\u51B3\u65B9\u6CD5\uFF0C\u53EA\u662F\u8FD8\u6CA1\u6709\u53D1\u73B0\u800C\u5DF2\u3002'</span>,\n beforeClose,\n});\n</code></pre>\n</div><div class="van-doc-card"><h3 id="shi-yong-dialog-zu-jian" tabindex="-1">\u4F7F\u7528 Dialog \u7EC4\u4EF6</h3>\n<p>\u5982\u679C\u4F60\u9700\u8981\u5728 Dialog \u5185\u5D4C\u5165\u7EC4\u4EF6\u6216\u5176\u4ED6\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 Dialog \u7EC4\u4EF6\uFF0C\u5E76\u4F7F\u7528\u9ED8\u8BA4\u63D2\u69FD\u8FDB\u884C\u5B9A\u5236\u3002\u4F7F\u7528\u524D\u9700\u8981\u901A\u8FC7 <code>app.use</code> \u7B49\u65B9\u5F0F\u6CE8\u518C\u7EC4\u4EF6\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-dialog</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"\u6807\u9898"</span> <span class="hljs-attr">show-cancel-button</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://fastly.jsdelivr.net/npm/@vant/assets/apple-3.jpeg"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-dialog</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">false</span>);\n <span class="hljs-keyword">return</span> { show };\n },\n};\n</code></pre>\n</div><h2 id="api" tabindex="-1">API</h2>\n<div class="van-doc-card"><h3 id="fang-fa" tabindex="-1">\u65B9\u6CD5</h3>\n<p>Vant \u4E2D\u5BFC\u51FA\u4E86\u4EE5\u4E0B Dialog \u76F8\u5173\u7684\u8F85\u52A9\u51FD\u6570\uFF1A</p>\n<table>\n<thead>\n<tr>\n<th>\u65B9\u6CD5\u540D</th>\n<th>\u8BF4\u660E</th>\n<th>\u53C2\u6570</th>\n<th>\u8FD4\u56DE\u503C</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>showDialog</td>\n<td>\u5C55\u793A\u6D88\u606F\u63D0\u793A\u5F39\u7A97\uFF0C\u9ED8\u8BA4\u5305\u542B\u786E\u8BA4\u6309\u94AE</td>\n<td><em>options: DialogOptions</em></td>\n<td><code>Promise<void></code></td>\n</tr>\n<tr>\n<td>showConfirmDialog</td>\n<td>\u5C55\u793A\u6D88\u606F\u786E\u8BA4\u5F39\u7A97\uFF0C\u9ED8\u8BA4\u5305\u542B\u786E\u8BA4\u548C\u53D6\u6D88\u6309\u94AE</td>\n<td><em>options: DialogOptions</em></td>\n<td><code>Promise<void></code></td>\n</tr>\n<tr>\n<td>closeDialog</td>\n<td>\u5173\u95ED\u5F53\u524D\u5C55\u793A\u7684\u5F39\u7A97</td>\n<td>-</td>\n<td><code>void</code></td>\n</tr>\n<tr>\n<td>setDialogDefaultOptions</td>\n<td>\u4FEE\u6539\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 <code>showDialog</code> \u8C03\u7528</td>\n<td><em>options: DialogOptions</em></td>\n<td><code>void</code></td>\n</tr>\n<tr>\n<td>resetDialogDefaultOptions</td>\n<td>\u91CD\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 <code>showDialog</code> \u8C03\u7528</td>\n<td>-</td>\n<td><code>void</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="dialogoptions" tabindex="-1">DialogOptions</h3>\n<p>\u8C03\u7528 <code>showDialog</code> \u7B49\u65B9\u6CD5\u65F6\uFF0C\u652F\u6301\u4F20\u5165\u4EE5\u4E0B\u9009\u9879\uFF1A</p>\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>title</td>\n<td>\u6807\u9898</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>width</td>\n<td>\u5F39\u7A97\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A <code>px</code></td>\n<td><em>number | string</em></td>\n<td><code>320px</code></td>\n</tr>\n<tr>\n<td>message</td>\n<td>\u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7 <code>\\n</code> \u6362\u884C</td>\n<td><em>string | () => JSX.ELement</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>messageAlign</td>\n<td>\u5185\u5BB9\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A <code>left</code> <code>right</code></td>\n<td><em>string</em></td>\n<td><code>center</code></td>\n</tr>\n<tr>\n<td>theme</td>\n<td>\u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3A <code>round-button</code></td>\n<td><em>string</em></td>\n<td><code>default</code></td>\n</tr>\n<tr>\n<td>className</td>\n<td>\u81EA\u5B9A\u4E49\u7C7B\u540D</td>\n<td><em>string | Array | object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>showConfirmButton</td>\n<td>\u662F\u5426\u5C55\u793A\u786E\u8BA4\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>showCancelButton</td>\n<td>\u662F\u5426\u5C55\u793A\u53D6\u6D88\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>confirmButtonText</td>\n<td>\u786E\u8BA4\u6309\u94AE\u6587\u6848</td>\n<td><em>string</em></td>\n<td><code>\u786E\u8BA4</code></td>\n</tr>\n<tr>\n<td>confirmButtonColor</td>\n<td>\u786E\u8BA4\u6309\u94AE\u989C\u8272</td>\n<td><em>string</em></td>\n<td><code>#ee0a24</code></td>\n</tr>\n<tr>\n<td>confirmButtonDisabled</td>\n<td>\u662F\u5426\u7981\u7528\u786E\u8BA4\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>cancelButtonText</td>\n<td>\u53D6\u6D88\u6309\u94AE\u6587\u6848</td>\n<td><em>string</em></td>\n<td><code>\u53D6\u6D88</code></td>\n</tr>\n<tr>\n<td>cancelButtonColor</td>\n<td>\u53D6\u6D88\u6309\u94AE\u989C\u8272</td>\n<td><em>string</em></td>\n<td><code>black</code></td>\n</tr>\n<tr>\n<td>cancelButtonDisabled</td>\n<td>\u662F\u5426\u7981\u7528\u53D6\u6D88\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>overlay</td>\n<td>\u662F\u5426\u5C55\u793A\u906E\u7F69\u5C42</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>overlayClass</td>\n<td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D</td>\n<td><em>string | Array | object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>overlayStyle</td>\n<td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F</td>\n<td><em>object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>closeOnPopstate</td>\n<td>\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95ED</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>closeOnClickOverlay</td>\n<td>\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED\u5F39\u7A97</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>lockScroll</td>\n<td>\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>allowHtml</td>\n<td>\u662F\u5426\u5141\u8BB8 message \u5185\u5BB9\u4E2D\u6E32\u67D3 HTML</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>beforeClose</td>\n<td>\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE <code>false</code> \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise</td>\n<td><em>(action: string) => boolean | Promise<boolean></em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>transition</td>\n<td>\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E <a href="https://cn.vuejs.org/api/built-in-components.html#transition" target="_blank">transition</a> \u7684 <code>name</code> \u5C5E\u6027</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>teleport</td>\n<td>\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 <a href="https://cn.vuejs.org/api/built-in-components.html#teleport" target="_blank">to \u5C5E\u6027</a></td>\n<td><em>string | Element</em></td>\n<td><code>body</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="props" tabindex="-1">Props</h3>\n<p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>Dialog</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B Props\uFF1A</p>\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>v-model:show</td>\n<td>\u662F\u5426\u663E\u793A\u5F39\u7A97</td>\n<td><em>boolean</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>title</td>\n<td>\u6807\u9898</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>width</td>\n<td>\u5F39\u7A97\u5BBD\u5EA6\uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A <code>px</code></td>\n<td><em>number | string</em></td>\n<td><code>320px</code></td>\n</tr>\n<tr>\n<td>message</td>\n<td>\u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7 <code>\\n</code> \u6362\u884C</td>\n<td><em>string | () => JSX.Element</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>message-align</td>\n<td>\u5185\u5BB9\u6C34\u5E73\u5BF9\u9F50\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A <code>left</code> <code>right</code> <code>justify</code></td>\n<td><em>string</em></td>\n<td><code>center</code></td>\n</tr>\n<tr>\n<td>theme</td>\n<td>\u6837\u5F0F\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3A <code>round-button</code></td>\n<td><em>string</em></td>\n<td><code>default</code></td>\n</tr>\n<tr>\n<td>show-confirm-button</td>\n<td>\u662F\u5426\u5C55\u793A\u786E\u8BA4\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>show-cancel-button</td>\n<td>\u662F\u5426\u5C55\u793A\u53D6\u6D88\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>confirm-button-text</td>\n<td>\u786E\u8BA4\u6309\u94AE\u6587\u6848</td>\n<td><em>string</em></td>\n<td><code>\u786E\u8BA4</code></td>\n</tr>\n<tr>\n<td>confirm-button-color</td>\n<td>\u786E\u8BA4\u6309\u94AE\u989C\u8272</td>\n<td><em>string</em></td>\n<td><code>#ee0a24</code></td>\n</tr>\n<tr>\n<td>confirm-button-disabled</td>\n<td>\u662F\u5426\u7981\u7528\u786E\u8BA4\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>cancel-button-text</td>\n<td>\u53D6\u6D88\u6309\u94AE\u6587\u6848</td>\n<td><em>string</em></td>\n<td><code>\u53D6\u6D88</code></td>\n</tr>\n<tr>\n<td>cancel-button-color</td>\n<td>\u53D6\u6D88\u6309\u94AE\u989C\u8272</td>\n<td><em>string</em></td>\n<td><code>black</code></td>\n</tr>\n<tr>\n<td>cancel-button-disabled</td>\n<td>\u662F\u5426\u7981\u7528\u53D6\u6D88\u6309\u94AE</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>z-index</td>\n<td>\u5C06\u5F39\u7A97\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503C</td>\n<td><em>number | string</em></td>\n<td><code>2000+</code></td>\n</tr>\n<tr>\n<td>overlay</td>\n<td>\u662F\u5426\u5C55\u793A\u906E\u7F69\u5C42</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>overlay-class</td>\n<td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>overlay-style</td>\n<td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F</td>\n<td><em>object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>close-on-popstate</td>\n<td>\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95ED</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>close-on-click-overlay</td>\n<td>\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED\u5F39\u7A97</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>lazy-render</td>\n<td>\u662F\u5426\u5728\u663E\u793A\u5F39\u5C42\u65F6\u624D\u6E32\u67D3\u8282\u70B9</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>lock-scroll</td>\n<td>\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>allow-html</td>\n<td>\u662F\u5426\u5141\u8BB8 message \u5185\u5BB9\u4E2D\u6E32\u67D3 HTML</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>before-close</td>\n<td>\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE <code>false</code> \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise</td>\n<td><em>(action: string) => boolean | Promise<boolean></em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>transition</td>\n<td>\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E <a href="https://cn.vuejs.org/api/built-in-components.html#transition" target="_blank">transition</a> \u7684 <code>name</code> \u5C5E\u6027</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>teleport</td>\n<td>\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 <a href="https://cn.vuejs.org/api/built-in-components.html#teleport" target="_blank">to \u5C5E\u6027</a></td>\n<td><em>string | Element</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="events" tabindex="-1">Events</h3>\n<p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>Dialog</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u4E8B\u4EF6\uFF1A</p>\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>confirm</td>\n<td>\u70B9\u51FB\u786E\u8BA4\u6309\u94AE\u65F6\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n<tr>\n<td>cancel</td>\n<td>\u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n<tr>\n<td>open</td>\n<td>\u6253\u5F00\u5F39\u7A97\u65F6\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n<tr>\n<td>close</td>\n<td>\u5173\u95ED\u5F39\u7A97\u65F6\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n<tr>\n<td>opened</td>\n<td>\u6253\u5F00\u5F39\u7A97\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n<tr>\n<td>closed</td>\n<td>\u5173\u95ED\u5F39\u7A97\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1</td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="slots" tabindex="-1">Slots</h3>\n<p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>Dialog</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u63D2\u69FD\uFF1A</p>\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>\u81EA\u5B9A\u4E49\u5185\u5BB9</td>\n</tr>\n<tr>\n<td>title</td>\n<td>\u81EA\u5B9A\u4E49\u6807\u9898</td>\n</tr>\n<tr>\n<td>footer</td>\n<td>\u81EA\u5B9A\u4E49\u5E95\u90E8\u6309\u94AE\u533A\u57DF</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> {\n <span class="hljs-title class_">DialogProps</span>,\n <span class="hljs-title class_">DialogTheme</span>,\n <span class="hljs-title class_">DialogMessage</span>,\n <span class="hljs-title class_">DialogOptions</span>,\n <span class="hljs-title class_">DialogMessageAlign</span>,\n} <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-dialog-width</td>\n<td><em>320px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-small-screen-width</td>\n<td><em>90%</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-font-size</td>\n<td><em>var(--van-font-size-lg)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-transition</td>\n<td><em>var(--van-duration-base)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-radius</td>\n<td><em>16px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-background</td>\n<td><em>var(--van-background-2)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-header-font-weight</td>\n<td><em>var(--van-font-bold)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-header-line-height</td>\n<td><em>24px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-header-padding-top</td>\n<td><em>26px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-header-isolated-padding</td>\n<td><em>var(--van-padding-lg) 0</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-message-padding</td>\n<td><em>var(--van-padding-lg)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-message-font-size</td>\n<td><em>var(--van-font-size-md)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-message-line-height</td>\n<td><em>var(--van-line-height-md)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-message-max-height</td>\n<td><em>60vh</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-has-title-message-text-color</td>\n<td><em>var(--van-gray-7)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-has-title-message-padding-top</td>\n<td><em>var(--van-padding-xs)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-button-height</td>\n<td><em>48px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-round-button-height</td>\n<td><em>36px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-dialog-confirm-button-text-color</td>\n<td><em>var(--van-primary-color)</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id="chang-jian-wen-ti" tabindex="-1">\u5E38\u89C1\u95EE\u9898</h2>\n<div class="van-doc-card"><h3 id="yin-yong-showdialog-shi-chu-xian-bian-yi-bao-cuo" tabindex="-1">\u5F15\u7528 showDialog \u65F6\u51FA\u73B0\u7F16\u8BD1\u62A5\u9519\uFF1F</h3>\n<p>\u5982\u679C\u5F15\u7528 <code>showDialog</code> \u65B9\u6CD5\u65F6\u51FA\u73B0\u4EE5\u4E0B\u62A5\u9519\uFF0C\u8BF4\u660E\u9879\u76EE\u4E2D\u4F7F\u7528\u4E86 <code>babel-plugin-import</code> \u63D2\u4EF6\uFF0C\u5BFC\u81F4\u4EE3\u7801\u88AB\u9519\u8BEF\u7F16\u8BD1\u3002</p>\n<pre><code class="language-bash">These dependencies were not found:\n\n* vant/es/show-dialog <span class="hljs-keyword">in</span> ./src/xxx.js\n* vant/es/show-dialog/style <span class="hljs-keyword">in</span> ./src/xxx.js\n</code></pre>\n<p>Vant \u4ECE 4.0 \u7248\u672C\u5F00\u59CB\u4E0D\u518D\u652F\u6301 <code>babel-plugin-import</code> \u63D2\u4EF6\uFF0C\u8BF7\u53C2\u8003 <a href="#/zh-CN/migrate-from-v3#yi-chu-babel-plugin-import" target="_blank">\u8FC1\u79FB\u6307\u5357</a> \u79FB\u9664\u8BE5\u63D2\u4EF6\u3002</p>\n</div><div class="van-doc-card"><h3 id="zai-beforerouteleave-li-diao-yong-dialog-wu-fa-zhan-shi" tabindex="-1">\u5728 beforeRouteLeave \u91CC\u8C03\u7528 Dialog \u65E0\u6CD5\u5C55\u793A\uFF1F</h3>\n<p>\u5C06 <code>closeOnPopstate</code> \u5C5E\u6027\u8BBE\u7F6E\u4E3A false \u5373\u53EF\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { showDialog } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n\n<span class="hljs-title function_">showDialog</span>({\n <span class="hljs-attr">title</span>: <span class="hljs-string">'\u6807\u9898'</span>,\n <span class="hljs-attr">message</span>: <span class="hljs-string">'\u5F39\u7A97\u5185\u5BB9'</span>,\n <span class="hljs-attr">closeOnPopstate</span>: <span class="hljs-literal">false</span>,\n}).<span class="hljs-title function_">then</span>(<span class="hljs-function">() =></span> {\n <span class="hljs-comment">// on close</span>\n});\n</code></pre>\n</div>'},null,8,a))}}}]); |