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

Popover \u6C14\u6CE1\u5F39\u51FA\u6846

\n

\u4ECB\u7ECD

\n

\u5F39\u51FA\u5F0F\u7684\u6C14\u6CE1\u83DC\u5355\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 { Popover } from 'vant';\n\nconst app = createApp();\napp.use(Popover);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

\u5F53 Popover \u5F39\u51FA\u65F6\uFF0C\u4F1A\u57FA\u4E8E reference \u63D2\u69FD\u7684\u5185\u5BB9\u8FDB\u884C\u5B9A\u4F4D\u3002

\n
<van-popover v-model:show="showPopover" :actions="actions" @select="onSelect">\n  <template #reference>\n    <van-button type="primary">\u6D45\u8272\u98CE\u683C</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n\n    // \u901A\u8FC7 actions \u5C5E\u6027\u6765\u5B9A\u4E49\u83DC\u5355\u9009\u9879\n    const actions = [\n      { text: '\u9009\u9879\u4E00' },\n      { text: '\u9009\u9879\u4E8C' },\n      { text: '\u9009\u9879\u4E09' },\n    ];\n    const onSelect = (action) => showToast(action.text);\n\n    return {\n      actions,\n      onSelect,\n      showPopover,\n    };\n  },\n};\n
\n

\u6DF1\u8272\u98CE\u683C

\n

Popover \u652F\u6301\u6D45\u8272\u548C\u6DF1\u8272\u4E24\u79CD\u98CE\u683C\uFF0C\u9ED8\u8BA4\u4E3A\u6D45\u8272\u98CE\u683C\uFF0C\u5C06 theme \u5C5E\u6027\u8BBE\u7F6E\u4E3A dark \u53EF\u5207\u6362\u4E3A\u6DF1\u8272\u98CE\u683C\u3002

\n
<van-popover v-model:show="showPopover" theme="dark" :actions="actions">\n  <template #reference>\n    <van-button type="primary">\u6DF1\u8272\u98CE\u683C</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n    const actions = [\n      { text: '\u9009\u9879\u4E00' },\n      { text: '\u9009\u9879\u4E8C' },\n      { text: '\u9009\u9879\u4E09' },\n    ];\n\n    return {\n      actions,\n      showPopover,\n    };\n  },\n};\n
\n

\u6C34\u5E73\u6392\u5217

\n

\u5C06 actions-direction \u5C5E\u6027\u8BBE\u7F6E\u4E3A horizontal \u540E\uFF0C\u83DC\u5355\u9009\u9879\u4F1A\u53D8\u6210\u6C34\u5E73\u6392\u5217\u3002

\n
<van-popover\n  v-model:show="showPopover"\n  :actions="actions"\n  actions-direction="horizontal"\n>\n  <template #reference>\n    <van-button type="primary">\u6C34\u5E73\u6392\u5217</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n    const actions = [\n      { text: '\u9009\u9879\u4E00' },\n      { text: '\u9009\u9879\u4E8C' },\n      { text: '\u9009\u9879\u4E09' },\n    ];\n\n    return {\n      actions,\n      showPopover,\n    };\n  },\n};\n
\n

\u5F39\u51FA\u4F4D\u7F6E

\n

\u901A\u8FC7 placement \u5C5E\u6027\u6765\u63A7\u5236\u6C14\u6CE1\u7684\u5F39\u51FA\u4F4D\u7F6E\u3002

\n
<van-popover placement="top" />\n
\n

placement \u652F\u6301\u4EE5\u4E0B\u503C\uFF1A

\n
top           # \u9876\u90E8\u4E2D\u95F4\u4F4D\u7F6E\ntop-start     # \u9876\u90E8\u5DE6\u4FA7\u4F4D\u7F6E\ntop-end       # \u9876\u90E8\u53F3\u4FA7\u4F4D\u7F6E\nleft          # \u5DE6\u4FA7\u4E2D\u95F4\u4F4D\u7F6E\nleft-start    # \u5DE6\u4FA7\u4E0A\u65B9\u4F4D\u7F6E\nleft-end      # \u5DE6\u4FA7\u4E0B\u65B9\u4F4D\u7F6E\nright         # \u53F3\u4FA7\u4E2D\u95F4\u4F4D\u7F6E\nright-start   # \u53F3\u4FA7\u4E0A\u65B9\u4F4D\u7F6E\nright-end     # \u53F3\u4FA7\u4E0B\u65B9\u4F4D\u7F6E\nbottom        # \u5E95\u90E8\u4E2D\u95F4\u4F4D\u7F6E\nbottom-start  # \u5E95\u90E8\u5DE6\u4FA7\u4F4D\u7F6E\nbottom-end    # \u5E95\u90E8\u53F3\u4FA7\u4F4D\u7F6E\n
\n

\u5C55\u793A\u56FE\u6807

\n

\u5728 actions \u6570\u7EC4\u4E2D\uFF0C\u53EF\u4EE5\u901A\u8FC7 icon \u5B57\u6BB5\u6765\u5B9A\u4E49\u9009\u9879\u7684\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

\n
<van-popover v-model:show="showPopover" :actions="actions">\n  <template #reference>\n    <van-button type="primary">\u5C55\u793A\u56FE\u6807</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n    const actions = [\n      { text: '\u9009\u9879\u4E00', icon: 'add-o' },\n      { text: '\u9009\u9879\u4E8C', icon: 'music-o' },\n      { text: '\u9009\u9879\u4E09', icon: 'more-o' },\n    ];\n\n    return {\n      actions,\n      showPopover,\n    };\n  },\n};\n
\n

\u7981\u7528\u9009\u9879

\n

\u5728 actions \u6570\u7EC4\u4E2D\uFF0C\u53EF\u4EE5\u901A\u8FC7 disabled \u5B57\u6BB5\u6765\u7981\u7528\u67D0\u4E2A\u9009\u9879\u3002

\n
<van-popover v-model:show="showPopover" :actions="actions">\n  <template #reference>\n    <van-button type="primary">\u7981\u7528\u9009\u9879</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n    const actions = [\n      { text: '\u9009\u9879\u4E00', disabled: true },\n      { text: '\u9009\u9879\u4E8C', disabled: true },\n      { text: '\u9009\u9879\u4E09' },\n    ];\n\n    return {\n      actions,\n      showPopover,\n    };\n  },\n};\n
\n

\u81EA\u5B9A\u4E49\u5185\u5BB9

\n

\u901A\u8FC7\u9ED8\u8BA4\u63D2\u69FD\uFF0C\u53EF\u4EE5\u5728 Popover \u5185\u90E8\u653E\u7F6E\u4EFB\u610F\u5185\u5BB9\u3002

\n
<van-popover v-model:show="showPopover">\n  <van-grid\n    square\n    clickable\n    :border="false"\n    column-num="3"\n    style="width: 240px;"\n  >\n    <van-grid-item\n      v-for="i in 6"\n      :key="i"\n      text="\u9009\u9879"\n      icon="photo-o"\n      @click="showPopover = false"\n    />\n  </van-grid>\n  <template #reference>\n    <van-button type="primary">\u81EA\u5B9A\u4E49\u5185\u5BB9</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showPopover = ref(false);\n    return { showPopover };\n  },\n};\n
\n

\u975E\u53D7\u63A7\u6A21\u5F0F

\n

\u4F60\u53EF\u4EE5\u628A Popover \u5F53\u505A\u53D7\u63A7\u7EC4\u4EF6\u6216\u975E\u53D7\u63A7\u7EC4\u4EF6\u4F7F\u7528\uFF1A

\n\n
<van-popover :actions="actions" position="top-start" @select="onSelect">\n  <template #reference>\n    <van-button type="primary">\u975E\u53D7\u63A7\u6A21\u5F0F</van-button>\n  </template>\n</van-popover>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const actions = [\n      { text: '\u9009\u9879\u4E00' },\n      { text: '\u9009\u9879\u4E8C' },\n      { text: '\u9009\u9879\u4E09' },\n    ];\n    const onSelect = (action) => showToast(action.text);\n    return {\n      actions,\n      onSelect,\n    };\n  },\n};\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
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
v-model:show\u662F\u5426\u5C55\u793A\u6C14\u6CE1\u5F39\u51FA\u5C42booleanfalse
actions\u9009\u9879\u5217\u8868PopoverAction[][]
actions-direction v4.4.1\u9009\u9879\u5217\u8868\u7684\u6392\u5217\u65B9\u5411\uFF0C\u53EF\u9009\u503C\u4E3A horizontalPopoverActionsDirectionvertical
placement\u5F39\u51FA\u4F4D\u7F6EPopoverPlacementbottom
theme\u4E3B\u9898\u98CE\u683C\uFF0C\u53EF\u9009\u503C\u4E3A darkPopoverThemelight
trigger\u89E6\u53D1\u65B9\u5F0F\uFF0C\u53EF\u9009\u503C\u4E3A manualPopoverTriggerclick
duration\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u79D2\uFF0C\u8BBE\u7F6E\u4E3A 0 \u53EF\u4EE5\u7981\u7528\u52A8\u753Bnumber | string0.3
offset\u51FA\u73B0\u4F4D\u7F6E\u7684\u504F\u79FB\u91CF[number, number][0, 8]
overlay\u662F\u5426\u663E\u793A\u906E\u7F69\u5C42booleanfalse
overlay-class\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540Dstring | Array | object-
overlay-style\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0Fobject-
show-arrow\u662F\u5426\u5C55\u793A\u5C0F\u7BAD\u5934booleantrue
close-on-click-action\u662F\u5426\u5728\u70B9\u51FB\u9009\u9879\u540E\u5173\u95EDbooleantrue
close-on-click-outside\u662F\u5426\u5728\u70B9\u51FB\u5916\u90E8\u5143\u7D20\u540E\u5173\u95ED\u83DC\u5355booleantrue
close-on-click-overlay\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED\u83DC\u5355booleantrue
teleport\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 to \u5C5E\u6027string | Elementbody
icon-prefix\u56FE\u6807\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027stringvan-icon
\n

PopoverAction \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
\u952E\u540D\u8BF4\u660E\u7C7B\u578B
text\u9009\u9879\u6587\u5B57string
icon\u6587\u5B57\u5DE6\u4FA7\u7684\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\u6027string
color\u9009\u9879\u6587\u5B57\u989C\u8272string
disabled\u662F\u5426\u4E3A\u7981\u7528\u72B6\u6001boolean
className\u4E3A\u5BF9\u5E94\u9009\u9879\u6DFB\u52A0\u989D\u5916\u7684\u7C7B\u540Dstring | Array | object
\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
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
select\u70B9\u51FB\u9009\u9879\u65F6\u89E6\u53D1action: PopoverAction, index: number
open\u6253\u5F00\u83DC\u5355\u65F6\u89E6\u53D1-
close\u5173\u95ED\u83DC\u5355\u65F6\u89E6\u53D1-
opened\u6253\u5F00\u83DC\u5355\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1-
closed\u5173\u95ED\u83DC\u5355\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
\u540D\u79F0\u8BF4\u660E\u53C2\u6570
default\u81EA\u5B9A\u4E49\u83DC\u5355\u5185\u5BB9-
reference\u89E6\u53D1 Popover \u663E\u793A\u7684\u5143\u7D20\u5185\u5BB9-
action\u81EA\u5B9A\u4E49\u9009\u9879\u5185\u5BB9{ action: PopoverAction, index: number }
\n

\u7C7B\u578B\u5B9A\u4E49

\n

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

\n
import type {\n  PopoverProps,\n  PopoverTheme,\n  PopoverAction,\n  PopoverActionsDirection,\n  PopoverTrigger,\n  PopoverPlacement,\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\n\n\n\n\n\n\n\n\n\n\n\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-popover-arrow-size6px-
--van-popover-radiusvar(--van-radius-lg)-
--van-popover-action-width128px-
--van-popover-action-height44px-
--van-popover-action-font-sizevar(--van-font-size-md)-
--van-popover-action-line-heightvar(--van-line-height-md)-
--van-popover-action-icon-size20px-
--van-popover-horizontal-action-height34px-
--van-popover-horizontal-action-icon-size16px-
--van-popover-light-text-colorvar(--van-text-color)-
--van-popover-light-backgroundvar(--van-background-2)-
--van-popover-light-action-disabled-text-colorvar(--van-text-color-3)-
--van-popover-dark-text-colorvar(--van-white)-
--van-popover-dark-background#4a4a4a-
--van-popover-dark-action-disabled-text-colorvar(--van-text-color-2)-
\n

\u5E38\u89C1\u95EE\u9898

\n

Popover \u7684\u70B9\u51FB\u4E8B\u4EF6\u65E0\u6CD5\u6B63\u786E\u89E6\u53D1\uFF1F

\n

\u8FD9\u79CD\u60C5\u51B5\u901A\u5E38\u662F\u7531\u4E8E\u9879\u76EE\u4E2D\u5F15\u5165\u4E86 fastclick \u5E93\u5BFC\u81F4\u7684\u3002\u5EFA\u8BAE\u79FB\u9664 fastclick\uFF0C\u6216\u8005\u914D\u7F6E fastclick \u7684 ignore \u89C4\u5219\u3002

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