/*! For license information please see 1021.0572424d.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["1021"],{63590: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:'

Notify \u6D88\u606F\u63D0\u793A

\n

\u4ECB\u7ECD

\n

\u5728\u9875\u9762\u9876\u90E8\u5C55\u793A\u6D88\u606F\u63D0\u793A\uFF0C\u652F\u6301\u7EC4\u4EF6\u8C03\u7528\u548C\u51FD\u6570\u8C03\u7528\u4E24\u79CD\u65B9\u5F0F\u3002

\n

\u5F15\u5165

\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

\n
import { createApp } from 'vue';\nimport { Notify } from 'vant';\n\nconst app = createApp();\napp.use(Notify);\n
\n

\u51FD\u6570\u8C03\u7528

\n

\u4E3A\u4E86\u4FBF\u4E8E\u4F7F\u7528 Notify\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\u6D88\u606F\u63D0\u793A\u3002

\n

\u6BD4\u5982\u4F7F\u7528 showNotify \u51FD\u6570\uFF0C\u8C03\u7528\u540E\u4F1A\u76F4\u63A5\u5728\u9875\u9762\u4E2D\u6E32\u67D3\u5BF9\u5E94\u7684\u63D0\u793A\u3002

\n
import { showNotify } from 'vant';\n\nshowNotify({ message: '\u63D0\u793A' });\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n
import { showNotify, closeNotify } from 'vant';\n\n// 3 \u79D2\u540E\u81EA\u52A8\u5173\u95ED\nshowNotify('\u901A\u77E5\u5185\u5BB9');\n\n// \u4E3B\u52A8\u5173\u95ED\ncloseNotify();\n
\n

\u901A\u77E5\u7C7B\u578B

\n

\u652F\u6301 primary\u3001success\u3001warning\u3001danger \u56DB\u79CD\u901A\u77E5\u7C7B\u578B\uFF0C\u9ED8\u8BA4\u4E3A danger\u3002

\n
import { showNotify } from 'vant';\n\n// \u4E3B\u8981\u901A\u77E5\nshowNotify({ type: 'primary', message: '\u901A\u77E5\u5185\u5BB9' });\n\n// \u6210\u529F\u901A\u77E5\nshowNotify({ type: 'success', message: '\u901A\u77E5\u5185\u5BB9' });\n\n// \u5371\u9669\u901A\u77E5\nshowNotify({ type: 'danger', message: '\u901A\u77E5\u5185\u5BB9' });\n\n// \u8B66\u544A\u901A\u77E5\nshowNotify({ type: 'warning', message: '\u901A\u77E5\u5185\u5BB9' });\n
\n

\u81EA\u5B9A\u4E49\u901A\u77E5

\n

\u81EA\u5B9A\u4E49\u6D88\u606F\u901A\u77E5\u7684\u989C\u8272\u3001\u4F4D\u7F6E\u548C\u5C55\u793A\u65F6\u957F\u3002

\n
import { showNotify } from 'vant';\n\nshowNotify({\n  message: '\u81EA\u5B9A\u4E49\u989C\u8272',\n  color: '#ad0000',\n  background: '#ffe1e1',\n});\n\nshowNotify({\n  message: '\u81EA\u5B9A\u4E49\u4F4D\u7F6E',\n  position: 'bottom',\n});\n\nshowNotify({\n  message: '\u81EA\u5B9A\u4E49\u65F6\u957F',\n  duration: 1000,\n});\n
\n

\u4F7F\u7528 Notify \u7EC4\u4EF6

\n

\u5982\u679C\u9700\u8981\u5728 Notify \u5185\u5D4C\u5165\u7EC4\u4EF6\u6216\u5176\u4ED6\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u53EF\u4EE5\u76F4\u63A5\u4F7F\u7528 Notify \u7EC4\u4EF6\uFF0C\u5E76\u4F7F\u7528\u9ED8\u8BA4\u63D2\u69FD\u8FDB\u884C\u5B9A\u5236\u3002\u4F7F\u7528\u524D\u9700\u8981\u901A\u8FC7 app.use \u7B49\u65B9\u5F0F\u6CE8\u518C\u7EC4\u4EF6\u3002

\n
<van-button type="primary" text="\u7EC4\u4EF6\u8C03\u7528" @click="showNotify" />\n<van-notify v-model:show="show" type="success">\n  <van-icon name="bell" style="margin-right: 4px;" />\n  <span>\u901A\u77E5\u5185\u5BB9</span>\n</van-notify>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const show = ref(false);\n\n    const showNotify = () => {\n      show.value = true;\n      setTimeout(() => {\n        show.value = false;\n      }, 2000);\n    };\n\n    return {\n      show,\n      showNotify,\n    };\n  },\n};\n
\n

API

\n

\u65B9\u6CD5

\n

Vant \u4E2D\u5BFC\u51FA\u4E86\u4EE5\u4E0B Notify \u76F8\u5173\u7684\u8F85\u52A9\u51FD\u6570\uFF1A

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
showNotify\u5728\u9875\u9762\u9876\u90E8\u5C55\u793A NotifyNotifyOptions | stringnotify \u5B9E\u4F8B
closeNotify\u5173\u95ED\u5F53\u524D\u5C55\u793A\u7684 Notify-void
setNotifyDefaultOptions\u4FEE\u6539\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 showNotify \u8C03\u7528NotifyOptionsvoid
resetNotifyDefaultOptions\u91CD\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u5F71\u54CD\u6240\u6709\u7684 showNotify \u8C03\u7528-void
\n

NotifyOptions

\n

\u8C03\u7528 showNotify \u7B49\u65B9\u6CD5\u65F6\uFF0C\u652F\u6301\u4F20\u5165\u4EE5\u4E0B\u9009\u9879\uFF1A

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
type\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary success warningNotifyTypedanger
message\u5C55\u793A\u6587\u6848\uFF0C\u652F\u6301\u901A\u8FC7\\n\u6362\u884Cstring-
duration\u5C55\u793A\u65F6\u957F(ms)\uFF0C\u503C\u4E3A 0 \u65F6\uFF0Cnotify \u4E0D\u4F1A\u6D88\u5931number | string3000
z-index\u5C06\u7EC4\u4EF6\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503Cnumber | string2000+
position\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A bottomNotifyPositiontop
color\u5B57\u4F53\u989C\u8272stringwhite
background\u80CC\u666F\u989C\u8272string-
className\u81EA\u5B9A\u4E49\u7C7B\u540Dstring | Array | object-
lockScroll\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8booleanfalse
teleport\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027string | Element-
onClick\u70B9\u51FB\u65F6\u7684\u56DE\u8C03\u51FD\u6570(event: MouseEvent): void-
onOpened\u5B8C\u5168\u5C55\u793A\u540E\u7684\u56DE\u8C03\u51FD\u6570() => void-
onClose\u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570() => void-
\n

Props

\n

\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Notify \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B Props\uFF1A

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
v-model:show\u662F\u5426\u663E\u793A\u901A\u77E5booleanfalse
type\u7C7B\u578B\uFF0C\u53EF\u9009\u503C\u4E3A primary success warningNotifyTypedanger
message\u5C55\u793A\u6587\u6848\uFF0C\u652F\u6301\u901A\u8FC7\\n\u6362\u884Cstring-
z-index\u5C06\u7EC4\u4EF6\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503Cnumber | string2000+
position\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A bottomNotifyPositiontop
color\u5B57\u4F53\u989C\u8272stringwhite
background\u80CC\u666F\u989C\u8272string-
class-name\u81EA\u5B9A\u4E49\u7C7B\u540Dstring | Array | object-
lock-scroll\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8booleanfalse
teleport\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027string | Element-
\n

Events

\n

\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Notify \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u4E8B\u4EF6\uFF1A

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
click\u70B9\u51FB\u65F6\u7684\u56DE\u8C03\u51FD\u6570event: MouseEvent
close\u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570-
opened\u5B8C\u5168\u5C55\u793A\u540E\u7684\u56DE\u8C03\u51FD\u6570-
\n

Slots

\n

\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 Notify \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u63D2\u69FD\uFF1A

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E
default\u81EA\u5B9A\u4E49\u5185\u5BB9
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type {\n  NotifyType,\n  NotifyProps,\n  NotifyOptions,\n  NotifyPosition,\n} from 'vant';\n
\n

\u4E3B\u9898\u5B9A\u5236

\n

\u6837\u5F0F\u53D8\u91CF

\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-notify-text-colorvar(--van-white)-
--van-notify-paddingvar(--van-padding-xs) var(--van-padding-md)-
--van-notify-font-sizevar(--van-font-size-md)-
--van-notify-line-heightvar(--van-line-height-md)-
--van-notify-primary-backgroundvar(--van-primary-color)-
--van-notify-success-backgroundvar(--van-success-color)-
--van-notify-danger-backgroundvar(--van-danger-color)-
--van-notify-warning-backgroundvar(--van-warning-color)-
\n

\u5E38\u89C1\u95EE\u9898

\n

\u5F15\u7528 showNotify \u65F6\u51FA\u73B0\u7F16\u8BD1\u62A5\u9519\uFF1F

\n

\u5982\u679C\u5F15\u7528 showNotify \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

\n
These dependencies were not found:\n\n* vant/es/show-notify in ./src/xxx.js\n* vant/es/show-notify/style in ./src/xxx.js\n
\n

Vant \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

\n
'},null,8,d))}}}]);