/*! For license information please see 3687.c99b59ad.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["3687"],{88454:function(n,s,t){"use strict";t.r(s);var a=t("80681");let d=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
\u5728\u9875\u9762\u4E2D\u95F4\u5F39\u51FA\u9ED1\u8272\u534A\u900F\u660E\u63D0\u793A\uFF0C\u7528\u4E8E\u6D88\u606F\u901A\u77E5\u3001\u52A0\u8F7D\u63D0\u793A\u3001\u64CD\u4F5C\u7ED3\u679C\u63D0\u793A\u7B49\u573A\u666F\u3002
\n\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002
\nimport { createApp } from 'vue';\nimport { Toast } from 'vant';\n\nconst app = createApp();\napp.use(Toast);\n
\n\u4E3A\u4E86\u4FBF\u4E8E\u4F7F\u7528 Toast
\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 Toast \u7EC4\u4EF6\u3002
\u6BD4\u5982\u4F7F\u7528 showToast
\u51FD\u6570\uFF0C\u8C03\u7528\u540E\u4F1A\u76F4\u63A5\u5728\u9875\u9762\u4E2D\u6E32\u67D3\u5BF9\u5E94\u7684\u8F7B\u63D0\u793A\u3002
import { showToast } from 'vant';\n\nshowToast('\u63D0\u793A\u5185\u5BB9');\n
\n\u4F7F\u7528 showToast
\u65B9\u6CD5\u5728\u5C4F\u5E55\u4E2D\u95F4\u5C55\u793A\u4E00\u6761\u6587\u5B57\u63D0\u793A\u3002
import { showToast } from 'vant';\n\nshowToast('\u63D0\u793A\u5185\u5BB9');\n
\n\u4F7F\u7528 showLoadingToast
\u65B9\u6CD5\u5C55\u793A\u52A0\u8F7D\u63D0\u793A\uFF0C\u901A\u8FC7 forbidClick
\u9009\u9879\u53EF\u4EE5\u7981\u7528\u80CC\u666F\u70B9\u51FB\u3002
import { showLoadingToast } from 'vant';\n\nshowLoadingToast({\n message: '\u52A0\u8F7D\u4E2D...',\n forbidClick: true,\n});\n
\n\u4F7F\u7528 showSuccessToast
\u65B9\u6CD5\u5C55\u793A\u6210\u529F\u63D0\u793A\uFF0C\u4F7F\u7528 showFailToast
\u65B9\u6CD5\u5C55\u793A\u5931\u8D25\u63D0\u793A\u3002
import { showSuccessToast, showFailToast } from 'vant';\n\nshowSuccessToast('\u6210\u529F\u6587\u6848');\nshowFailToast('\u5931\u8D25\u6587\u6848');\n
\n\u901A\u8FC7 icon
\u9009\u9879\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u652F\u6301\u4F20\u5165\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027\u3002
import { showToast } from 'vant';\n\nshowToast({\n message: '\u81EA\u5B9A\u4E49\u56FE\u6807',\n icon: 'like-o',\n});\n\nshowToast({\n message: '\u81EA\u5B9A\u4E49\u56FE\u7247',\n icon: 'https://fastly.jsdelivr.net/npm/@vant/assets/logo.png',\n});\n
\n\u901A\u8FC7 loadingType
\u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u52A0\u8F7D\u56FE\u6807\u7C7B\u578B\u3002
import { showLoadingToast } from 'vant';\n\nshowLoadingToast({\n message: '\u52A0\u8F7D\u4E2D...',\n forbidClick: true,\n loadingType: 'spinner',\n});\n
\nToast \u9ED8\u8BA4\u6E32\u67D3\u5728\u5C4F\u5E55\u6B63\u4E2D\u4F4D\u7F6E\uFF0C\u901A\u8FC7 position
\u5C5E\u6027\u53EF\u4EE5\u63A7\u5236 Toast \u5C55\u793A\u7684\u4F4D\u7F6E\u3002
import { showToast } from 'vant';\n\nshowToast({\n message: '\u9876\u90E8\u5C55\u793A',\n position: 'top',\n});\n\nshowToast({\n message: '\u5E95\u90E8\u5C55\u793A',\n position: 'bottom',\n});\n
\n\u901A\u8FC7 wordBreak
\u9009\u9879\u53EF\u4EE5\u63A7\u5236 Toast \u4E2D\u7684\u6587\u5B57\u8FC7\u957F\u65F6\u7684\u622A\u65AD\u65B9\u5F0F\uFF0C\u9ED8\u8BA4\u503C\u4E3A break-all
\uFF0C\u53EF\u9009\u503C\u4E3A break-word
\u548C normal
\u3002
import { showToast } from 'vant';\n\n// \u6362\u884C\u65F6\u622A\u65AD\u5355\u8BCD\nshowToast({\n message: 'This message will contain a incomprehensibilities long word.',\n wordBreak: 'break-all',\n});\n\n// \u6362\u884C\u65F6\u4E0D\u622A\u65AD\u5355\u8BCD\nshowToast({\n message: 'This message will contain a incomprehensibilities long word.',\n wordBreak: 'break-word',\n});\n
\n\u6267\u884C Toast \u65B9\u6CD5\u65F6\u4F1A\u8FD4\u56DE\u5BF9\u5E94\u7684 Toast \u5B9E\u4F8B\uFF0C\u901A\u8FC7\u4FEE\u6539\u5B9E\u4F8B\u4E0A\u7684 message
\u5C5E\u6027\u53EF\u4EE5\u5B9E\u73B0\u52A8\u6001\u66F4\u65B0\u63D0\u793A\u7684\u6548\u679C\u3002
import { showLoadingToast, closeToast } from 'vant';\n\nconst toast = showLoadingToast({\n duration: 0,\n forbidClick: true,\n message: '\u5012\u8BA1\u65F6 3 \u79D2',\n});\n\nlet second = 3;\nconst timer = setInterval(() => {\n second--;\n if (second) {\n toast.message = `\u5012\u8BA1\u65F6 ${second} \u79D2`;\n } else {\n clearInterval(timer);\n closeToast();\n }\n}, 1000);\n
\nToast \u9ED8\u8BA4\u91C7\u7528\u5355\u4F8B\u6A21\u5F0F\uFF0C\u5373\u540C\u4E00\u65F6\u95F4\u53EA\u4F1A\u5B58\u5728\u4E00\u4E2A Toast\uFF0C\u5982\u679C\u9700\u8981\u5728\u540C\u4E00\u65F6\u95F4\u5F39\u51FA\u591A\u4E2A Toast\uFF0C\u53EF\u4EE5\u53C2\u8003\u4E0B\u9762\u7684\u793A\u4F8B\uFF1A
\nimport { showToast, showSuccessToast, allowMultipleToast } from 'vant';\n\nallowMultipleToast();\n\nconst toast1 = showToast('\u7B2C\u4E00\u4E2A Toast');\nconst toast2 = showSuccessToast('\u7B2C\u4E8C\u4E2A Toast');\n\ntoast1.close();\ntoast2.close();\n
\n\u901A\u8FC7 setToastDefaultOptions
\u51FD\u6570\u53EF\u4EE5\u5168\u5C40\u4FEE\u6539 showToast
\u7B49\u65B9\u6CD5\u7684\u9ED8\u8BA4\u914D\u7F6E\u3002
import { setToastDefaultOptions, resetToastDefaultOptions } from 'vant';\n\nsetToastDefaultOptions({ duration: 2000 });\n\nsetToastDefaultOptions('loading', { forbidClick: true });\n\nresetToastDefaultOptions();\n\nresetToastDefaultOptions('loading');\n
\n\u5982\u679C\u4F60\u9700\u8981\u5728 Toast \u5185\u5D4C\u5165\u7EC4\u4EF6\u6216\u5176\u4ED6\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 Toast \u7EC4\u4EF6\uFF0C\u5E76\u4F7F\u7528 message \u63D2\u69FD\u8FDB\u884C\u5B9A\u5236\u3002\u4F7F\u7528\u524D\u9700\u8981\u901A\u8FC7 app.use
\u7B49\u65B9\u5F0F\u6CE8\u518C\u7EC4\u4EF6\u3002
<van-toast v-model:show="show" style="padding: 0">\n <template #message>\n <van-image :src="image" width="200" height="140" style="display: block" />\n </template>\n</van-toast>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const show = ref(false);\n return { show };\n },\n};\n
\nVant \u4E2D\u5BFC\u51FA\u4E86\u4EE5\u4E0B Toast \u76F8\u5173\u7684\u8F85\u52A9\u51FD\u6570\uFF1A
\n\u65B9\u6CD5\u540D | \n\u8BF4\u660E | \n\u53C2\u6570 | \n\u8FD4\u56DE\u503C | \n
---|---|---|---|
showToast | \n\u5C55\u793A\u6587\u5B57\u63D0\u793A | \nToastOptions | string | \nToast \u5B9E\u4F8B | \n
showLoadingToast | \n\u5C55\u793A\u52A0\u8F7D\u63D0\u793A | \nToastOptions | string | \nToast \u5B9E\u4F8B | \n
showSuccessToast | \n\u5C55\u793A\u6210\u529F\u63D0\u793A | \nToastOptions | string | \nToast \u5B9E\u4F8B | \n
showFailToast | \n\u5C55\u793A\u5931\u8D25\u63D0\u793A | \nToastOptions | string | \nToast \u5B9E\u4F8B | \n
closeToast | \n\u5173\u95ED\u5F53\u524D\u5C55\u793A\u7684\u63D0\u793A | \ncloseAll: boolean | \nvoid | \n
allowMultipleToast | \n\u5141\u8BB8\u540C\u65F6\u5B58\u5728\u591A\u4E2A Toast | \n- | \nvoid | \n
setToastDefaultOptions | \n\u4FEE\u6539\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 showToast \u8C03\u7528\u3002\u4F20\u5165 type \u53EF\u4EE5\u4FEE\u6539\u6307\u5B9A\u7C7B\u578B Toast \u7684\u9ED8\u8BA4\u914D\u7F6E | \ntype | ToastOptions | \nvoid | \n
resetToastDefaultOptions | \n\u91CD\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 showToast \u8C03\u7528\u3002\u4F20\u5165 type \u53EF\u4EE5\u91CD\u7F6E\u6307\u5B9A\u7C7B\u578B Toast \u7684\u9ED8\u8BA4\u914D\u7F6E | \ntype | \nvoid | \n
\u8C03\u7528 showToast
\u7B49\u65B9\u6CD5\u65F6\uFF0C\u652F\u6301\u4F20\u5165\u4EE5\u4E0B\u9009\u9879\uFF1A
\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4\u503C | \n
---|---|---|---|
type | \n\u63D0\u793A\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A loading success fail html | \nToastType | \ntext | \n
position | \n\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top bottom | \nToastPosition | \nmiddle | \n
message | \n\u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7\\n \u6362\u884C | \nstring | \n\'\' | \n
wordBreak | \n\u6587\u672C\u5185\u5BB9\u7684\u6362\u884C\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A normal break-all break-word | \nToastWordBreak | \n\'break-all\' | \n
icon | \n\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u652F\u6301\u4F20\u5165\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027 | \nstring | \n- | \n
iconSize | \n\u56FE\u6807\u5927\u5C0F\uFF0C\u5982 20px 2em \uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | \nnumber | string | \n36px | \n
iconPrefix | \n\u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027 | \nstring | \nvan-icon | \n
overlay | \n\u662F\u5426\u663E\u793A\u80CC\u666F\u906E\u7F69\u5C42 | \nboolean | \nfalse | \n
forbidClick | \n\u662F\u5426\u7981\u6B62\u80CC\u666F\u70B9\u51FB | \nboolean | \nfalse | \n
closeOnClick | \n\u662F\u5426\u5728\u70B9\u51FB\u540E\u5173\u95ED | \nboolean | \nfalse | \n
closeOnClickOverlay | \n\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED | \nboolean | \nfalse | \n
loadingType | \n\u52A0\u8F7D\u56FE\u6807\u7C7B\u578B, \u53EF\u9009\u503C\u4E3A spinner | \nstring | \ncircular | \n
duration | \n\u5C55\u793A\u65F6\u957F(ms)\uFF0C\u503C\u4E3A 0 \u65F6\uFF0Ctoast \u4E0D\u4F1A\u6D88\u5931 | \nnumber | \n2000 | \n
className | \n\u81EA\u5B9A\u4E49\u7C7B\u540D | \nstring | Array | object | \n- | \n
overlayClass | \n\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D | \nstring | Array | object | \n- | \n
overlayStyle | \n\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F | \nobject | \n- | \n
transition | \n\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E transition \u7684name \u5C5E\u6027 | \nstring | \nvan-fade | \n
teleport | \n\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027 | \nstring | Element | \nbody | \n
z-index | \n\u5C06\u7EC4\u4EF6\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503C | \nnumber | string | \n2000+ | \n
onClose | \n\u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570 | \nFunction | \n- | \n
onOpened | \n\u5B8C\u5168\u5C55\u793A\u540E\u7684\u56DE\u8C03\u51FD\u6570 | \nFunction | \n- | \n
\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Toast
\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B Props\uFF1A
\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4\u503C | \n
---|---|---|---|
type | \n\u63D0\u793A\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A loading success fail html | \nToastType | \ntext | \n
position | \n\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A top bottom | \nToastPosition | \nmiddle | \n
message | \n\u6587\u672C\u5185\u5BB9\uFF0C\u652F\u6301\u901A\u8FC7\\n \u6362\u884C | \nstring | \n\'\' | \n
word-break | \n\u6587\u672C\u5185\u5BB9\u7684\u6362\u884C\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A normal break-all break-word | \nToastWordBreak | \n\'break-all\' | \n
icon | \n\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u652F\u6301\u4F20\u5165\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027 | \nstring | \n- | \n
icon-size | \n\u56FE\u6807\u5927\u5C0F\uFF0C\u5982 20px 2em \uFF0C\u9ED8\u8BA4\u5355\u4F4D\u4E3A px | \nnumber | string | \n36px | \n
icon-prefix | \n\u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027 | \nstring | \nvan-icon | \n
overlay | \n\u662F\u5426\u663E\u793A\u80CC\u666F\u906E\u7F69\u5C42 | \nboolean | \nfalse | \n
forbid-click | \n\u662F\u5426\u7981\u6B62\u80CC\u666F\u70B9\u51FB | \nboolean | \nfalse | \n
close-on-click | \n\u662F\u5426\u5728\u70B9\u51FB\u540E\u5173\u95ED | \nboolean | \nfalse | \n
close-on-click-overlay | \n\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED | \nboolean | \nfalse | \n
loading-type | \n\u52A0\u8F7D\u56FE\u6807\u7C7B\u578B, \u53EF\u9009\u503C\u4E3A spinner | \nstring | \ncircular | \n
duration | \n\u5C55\u793A\u65F6\u957F(ms)\uFF0C\u503C\u4E3A 0 \u65F6\uFF0Ctoast \u4E0D\u4F1A\u6D88\u5931 | \nnumber | \n2000 | \n
class-name | \n\u81EA\u5B9A\u4E49\u7C7B\u540D | \nstring | Array | object | \n- | \n
overlay-class | \n\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D | \nstring | Array | object | \n- | \n
overlay-style | \n\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F | \nobject | \n- | \n
transition | \n\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E transition \u7684name \u5C5E\u6027 | \nstring | \nvan-fade | \n
teleport | \n\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027 | \nstring | Element | \nbody | \n
z-index | \n\u5C06\u7EC4\u4EF6\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503C | \nnumber | string | \n2000+ | \n
\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Toast
\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u4E8B\u4EF6\uFF1A
\u4E8B\u4EF6\u540D | \n\u8BF4\u660E | \n\u56DE\u8C03\u53C2\u6570 | \n
---|---|---|
close | \n\u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570 | \n- | \n
opened | \n\u5B8C\u5168\u5C55\u793A\u540E\u7684\u56DE\u8C03\u51FD\u6570 | \n- | \n
\u4F7F\u7528 Toast
\u7EC4\u4EF6\u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u63D2\u69FD\uFF1A
\u540D\u79F0 | \n\u8BF4\u660E | \n
---|---|
message | \n\u81EA\u5B9A\u4E49\u6587\u672C\u5185\u5BB9 | \n
\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A
\nimport type {\n ToastType,\n ToastProps,\n ToastOptions,\n ToastPosition,\n ToastWordBreak,\n ToastWrapperInstance,\n} from 'vant';\n
\n\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 ConfigProvider \u7EC4\u4EF6\u3002
\n\u540D\u79F0 | \n\u9ED8\u8BA4\u503C | \n\u63CF\u8FF0 | \n
---|---|---|
--van-toast-max-width | \n70% | \n- | \n
--van-toast-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-toast-text-color | \nvar(--van-white) | \n- | \n
--van-toast-loading-icon-color | \nvar(--van-white) | \n- | \n
--van-toast-line-height | \nvar(--van-line-height-md) | \n- | \n
--van-toast-radius | \nvar(--van-radius-lg) | \n- | \n
--van-toast-background | \nfade(var(--van-black), 70%) | \n- | \n
--van-toast-icon-size | \n36px | \n- | \n
--van-toast-text-min-width | \n96px | \n- | \n
--van-toast-text-padding | \nvar(--van-padding-xs) var(--van-padding-sm) | \n- | \n
--van-toast-default-padding | \nvar(--van-padding-md) | \n- | \n
--van-toast-default-width | \n88px | \n- | \n
--van-toast-default-min-height | \n88px | \n- | \n
--van-toast-position-top-distance | \n20% | \n- | \n
--van-toast-position-bottom-distance | \n20% | \n- | \n
\u5982\u679C\u5F15\u7528 showToast
\u65B9\u6CD5\u65F6\u51FA\u73B0\u4EE5\u4E0B\u62A5\u9519\uFF0C\u8BF4\u660E\u9879\u76EE\u4E2D\u4F7F\u7528\u4E86 babel-plugin-import
\u63D2\u4EF6\uFF0C\u5BFC\u81F4\u4EE3\u7801\u88AB\u9519\u8BEF\u7F16\u8BD1\u3002
These dependencies were not found:\n\n* vant/es/show-toast in ./src/xxx.js\n* vant/es/show-toast/style in ./src/xxx.js\n
\nVant \u4ECE 4.0 \u7248\u672C\u5F00\u59CB\u4E0D\u518D\u652F\u6301 babel-plugin-import
\u63D2\u4EF6\uFF0C\u8BF7\u53C2\u8003 \u8FC1\u79FB\u6307\u5357 \u79FB\u9664\u8BE5\u63D2\u4EF6\u3002