/*! For license information please see 5211.a8ebed25.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["5211"],{7149:function(n,s,t){"use strict";t.r(s);var a=t("80681");let e=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

ActionSheet \u52A8\u4F5C\u9762\u677F

\n

\u4ECB\u7ECD

\n

\u5E95\u90E8\u5F39\u8D77\u7684\u6A21\u6001\u9762\u677F\uFF0C\u5305\u542B\u4E0E\u5F53\u524D\u60C5\u5883\u76F8\u5173\u7684\u591A\u4E2A\u9009\u9879\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 { ActionSheet } from 'vant';\n\nconst app = createApp();\napp.use(ActionSheet);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

\u52A8\u4F5C\u9762\u677F\u901A\u8FC7 actions \u5C5E\u6027\u6765\u5B9A\u4E49\u9009\u9879\uFF0Cactions \u5C5E\u6027\u662F\u4E00\u4E2A\u7531\u5BF9\u8C61\u6784\u6210\u7684\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E2A\u5BF9\u8C61\u914D\u7F6E\u4E00\u5217\uFF0C\u5BF9\u8C61\u683C\u5F0F\u89C1\u6587\u6863\u4E0B\u65B9\u8868\u683C\u3002

\n
<van-cell is-link title="\u57FA\u7840\u7528\u6CD5" @click="show = true" />\n<van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" />\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const show = ref(false);\n    const actions = [\n      { name: '\u9009\u9879\u4E00' },\n      { name: '\u9009\u9879\u4E8C' },\n      { name: '\u9009\u9879\u4E09' },\n    ];\n    const onSelect = (item) => {\n      // \u9ED8\u8BA4\u60C5\u51B5\u4E0B\u70B9\u51FB\u9009\u9879\u65F6\u4E0D\u4F1A\u81EA\u52A8\u6536\u8D77\n      // \u53EF\u4EE5\u901A\u8FC7 close-on-click-action \u5C5E\u6027\u5F00\u542F\u81EA\u52A8\u6536\u8D77\n      show.value = false;\n      showToast(item.name);\n    };\n\n    return {\n      show,\n      actions,\n      onSelect,\n    };\n  },\n};\n
\n

\u5C55\u793A\u56FE\u6807

\n

\u4F7F\u7528 actions \u7684 icon \u5B57\u6BB5\u53EF\u4EE5\u4E3A\u9009\u9879\u8BBE\u7F6E\u56FE\u6807\u3002

\n
<van-cell is-link title="\u5C55\u793A\u56FE\u6807" @click="show = true" />\n<van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" />\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const show = ref(false);\n    const actions = [\n      { name: '\u9009\u9879\u4E00', icon: 'cart-o' },\n      { name: '\u9009\u9879\u4E8C', icon: 'shop-o' },\n      { name: '\u9009\u9879\u4E09', icon: 'star-o' },\n    ];\n    const onSelect = (item) => {\n      show.value = false;\n      showToast(item.name);\n    };\n\n    return {\n      show,\n      actions,\n      onSelect,\n    };\n  },\n};\n
\n

\u5C55\u793A\u53D6\u6D88\u6309\u94AE

\n

\u8BBE\u7F6E cancel-text \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u5E95\u90E8\u5C55\u793A\u53D6\u6D88\u6309\u94AE\uFF0C\u70B9\u51FB\u540E\u5173\u95ED\u5F53\u524D\u9762\u677F\u5E76\u89E6\u53D1 cancel \u4E8B\u4EF6\u3002

\n
<van-action-sheet\n  v-model:show="show"\n  :actions="actions"\n  cancel-text="\u53D6\u6D88"\n  close-on-click-action\n  @cancel="onCancel"\n/>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const show = ref(false);\n    const actions = [\n      { name: '\u9009\u9879\u4E00' },\n      { name: '\u9009\u9879\u4E8C' },\n      { name: '\u9009\u9879\u4E09' },\n    ];\n    const onCancel = () => showToast('\u53D6\u6D88');\n\n    return {\n      show,\n      actions,\n      onCancel,\n    };\n  },\n};\n
\n

\u5C55\u793A\u63CF\u8FF0\u4FE1\u606F

\n

\u901A\u8FC7 description \u53EF\u4EE5\u5728\u83DC\u5355\u9876\u90E8\u663E\u793A\u63CF\u8FF0\u4FE1\u606F\uFF0C\u901A\u8FC7\u9009\u9879\u7684 subname \u5C5E\u6027\u53EF\u4EE5\u5728\u9009\u9879\u6587\u5B57\u7684\u53F3\u4FA7\u5C55\u793A\u63CF\u8FF0\u4FE1\u606F\u3002

\n
<van-action-sheet\n  v-model:show="show"\n  :actions="actions"\n  cancel-text="\u53D6\u6D88"\n  description="\u8FD9\u662F\u4E00\u6BB5\u63CF\u8FF0\u4FE1\u606F"\n  close-on-click-action\n/>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const show = ref(false);\n    const actions = [\n      { name: '\u9009\u9879\u4E00' },\n      { name: '\u9009\u9879\u4E8C' },\n      { name: '\u9009\u9879\u4E09', subname: '\u63CF\u8FF0\u4FE1\u606F' },\n    ];\n\n    return {\n      show,\n      actions,\n    };\n  },\n};\n
\n

\u9009\u9879\u72B6\u6001

\n

\u53EF\u4EE5\u901A\u8FC7 loading \u548C disabled \u5C06\u9009\u9879\u8BBE\u7F6E\u4E3A\u52A0\u8F7D\u72B6\u6001\u6216\u7981\u7528\u72B6\u6001\uFF0C\u6216\u8005\u901A\u8FC7color\u8BBE\u7F6E\u9009\u9879\u7684\u989C\u8272

\n
<van-action-sheet\n  v-model:show="show"\n  :actions="actions"\n  cancel-text="\u53D6\u6D88"\n  close-on-click-action\n/>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const show = ref(false);\n    const actions = [\n      { name: '\u7740\u8272\u9009\u9879', color: '#ee0a24' },\n      { name: '\u7981\u7528\u9009\u9879', disabled: true },\n      { name: '\u52A0\u8F7D\u9009\u9879', loading: true },\n    ];\n\n    return {\n      show,\n      actions,\n    };\n  },\n};\n
\n

\u81EA\u5B9A\u4E49\u9762\u677F

\n

\u901A\u8FC7\u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u9762\u677F\u7684\u5C55\u793A\u5185\u5BB9\uFF0C\u540C\u65F6\u53EF\u4EE5\u4F7F\u7528title\u5C5E\u6027\u5C55\u793A\u6807\u9898\u680F

\n
<van-action-sheet v-model:show="show" title="\u6807\u9898">\n  <div class="content">\u5185\u5BB9</div>\n</van-action-sheet>\n\n<style>\n  .content {\n    padding: 16px 16px 160px;\n  }\n</style>\n
\n

API

\n

Props

\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\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\u52A8\u4F5C\u9762\u677Fbooleanfalse
actions\u9762\u677F\u9009\u9879\u5217\u8868ActionSheetAction[][]
title\u9876\u90E8\u6807\u9898string-
cancel-text\u53D6\u6D88\u6309\u94AE\u6587\u5B57string-
description\u9009\u9879\u4E0A\u65B9\u7684\u63CF\u8FF0\u4FE1\u606Fstring-
closeable\u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807booleantrue
close-icon\u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 name \u5C5E\u6027stringcross
duration\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u79D2\uFF0C\u8BBE\u7F6E\u4E3A 0 \u53EF\u4EE5\u7981\u7528\u52A8\u753Bnumber | string0.3
z-index\u5C06\u9762\u677F\u7684 z-index \u5C42\u7EA7\u8BBE\u7F6E\u4E3A\u4E00\u4E2A\u56FA\u5B9A\u503Cnumber | string2000+
round\u662F\u5426\u663E\u793A\u5706\u89D2booleantrue
overlay\u662F\u5426\u663E\u793A\u906E\u7F69\u5C42booleantrue
overlay-class\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540Dstring | Array | object-
overlay-style\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0Fobject-
lock-scroll\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8booleantrue
lazy-render\u662F\u5426\u5728\u663E\u793A\u5F39\u5C42\u65F6\u624D\u6E32\u67D3\u8282\u70B9booleantrue
close-on-popstate\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95EDbooleantrue
close-on-click-action\u662F\u5426\u5728\u70B9\u51FB\u9009\u9879\u540E\u5173\u95EDbooleanfalse
close-on-click-overlay\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95EDbooleantrue
safe-area-inset-bottom\u662F\u5426\u5F00\u542F\u5E95\u90E8\u5B89\u5168\u533A\u9002\u914Dbooleantrue
teleport\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027string | Element-
before-close\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE false \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise(action: string) => boolean | Promise<boolean>-
\n

Action \u6570\u636E\u7ED3\u6784

\n

actions \u5C5E\u6027\u662F\u4E00\u4E2A\u7531\u5BF9\u8C61\u6784\u6210\u7684\u6570\u7EC4\uFF0C\u6570\u7EC4\u4E2D\u7684\u6BCF\u4E2A\u5BF9\u8C61\u914D\u7F6E\u4E00\u5217\uFF0C\u5BF9\u8C61\u53EF\u4EE5\u5305\u542B\u4EE5\u4E0B\u503C\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
\u952E\u540D\u8BF4\u660E\u7C7B\u578B
name\u6807\u9898string
subname\u4E8C\u7EA7\u6807\u9898string
color\u9009\u9879\u6587\u5B57\u989C\u8272string
icon v4.8.6\u9009\u9879\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5string
className\u4E3A\u5BF9\u5E94\u5217\u6DFB\u52A0\u989D\u5916\u7684 classstring | Array | object
loading\u662F\u5426\u4E3A\u52A0\u8F7D\u72B6\u6001boolean
disabled\u662F\u5426\u4E3A\u7981\u7528\u72B6\u6001boolean
callback\u70B9\u51FB\u65F6\u89E6\u53D1\u7684\u56DE\u8C03\u51FD\u6570action: ActionSheetAction
\n

Events

\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
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
select\u70B9\u51FB\u9009\u9879\u65F6\u89E6\u53D1\uFF0C\u7981\u7528\u6216\u52A0\u8F7D\u72B6\u6001\u4E0B\u4E0D\u4F1A\u89E6\u53D1action: ActionSheetAction, index: number
cancel\u70B9\u51FB\u53D6\u6D88\u6309\u94AE\u65F6\u89E6\u53D1-
open\u6253\u5F00\u9762\u677F\u65F6\u89E6\u53D1-
close\u5173\u95ED\u9762\u677F\u65F6\u89E6\u53D1-
opened\u6253\u5F00\u9762\u677F\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1-
closed\u5173\u95ED\u9762\u677F\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1-
click-overlay\u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u89E6\u53D1event: MouseEvent
\n

Slots

\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\u8BF4\u660E\u53C2\u6570
default\u81EA\u5B9A\u4E49\u9762\u677F\u7684\u5C55\u793A\u5185\u5BB9-
description\u81EA\u5B9A\u4E49\u63CF\u8FF0\u6587\u6848-
cancel\u81EA\u5B9A\u4E49\u53D6\u6D88\u6309\u94AE\u5185\u5BB9-
action\u81EA\u5B9A\u4E49\u9009\u9879\u5185\u5BB9{ action: ActionSheetAction, index: number }
\n

\u7C7B\u578B\u5B9A\u4E49

\n

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

\n
import type { ActionSheetProps, ActionSheetAction } 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\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
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-action-sheet-max-height80%-
--van-action-sheet-header-height48px-
--van-action-sheet-header-font-sizevar(--van-font-size-lg)-
--van-action-sheet-description-colorvar(--van-text-color-2)-
--van-action-sheet-description-font-sizevar(--van-font-size-md)-
--van-action-sheet-description-line-heightvar(--van-line-height-md)-
--van-action-sheet-item-backgroundvar(--van-background-2)-
--van-action-sheet-item-font-sizevar(--van-font-size-lg)-
--van-action-sheet-item-line-heightvar(--van-line-height-lg)-
--van-action-sheet-item-text-colorvar(--van-text-color)-
--van-action-sheet-item-disabled-text-colorvar(--van-text-color-3)-
--van-action-sheet-item-icon-size18px-
--van-action-sheet-item-icon-margin-rightvar(--van-padding-xs)-
--van-action-sheet-subname-colorvar(--van-text-color-2)-
--van-action-sheet-subname-font-sizevar(--van-font-size-sm)-
--van-action-sheet-subname-line-heightvar(--van-line-height-sm)-
--van-action-sheet-close-icon-size22px-
--van-action-sheet-close-icon-colorvar(--van-gray-5)-
--van-action-sheet-close-icon-padding0 var(--van-padding-md)-
--van-action-sheet-cancel-text-colorvar(--van-gray-7)-
--van-action-sheet-cancel-padding-topvar(--van-padding-xs)-
--van-action-sheet-cancel-padding-colorvar(--van-background)-
--van-action-sheet-loading-icon-size22px-
\n
'},null,8,e))}}}]);