Skip to content

Popover 弹出框

用于在不打断用户流程的情况下展示补充信息和操作内容,支持标题、富文本内容、不同触发方式与位置控制。

何时使用

  • 需要在不打断用户流程的情况下展示补充信息和操作内容
  • 支持标题、富文本内容、不同触发方式与位置控制
  • 需要展示比 Tooltip 更复杂的内容和操作

基本用法

最简单的用法,点击触发显示弹出框。

悬停触发

鼠标悬停时显示弹出框。

自定义内容与标题插槽

支持自定义标题和内容插槽,可以插入任意 Vue 组件。

位置与主题

支持 12 个方向的位置和两种主题样式。

受控显示

通过 v-modelvisible 属性手动控制弹出框的显示状态。

右键菜单触发

支持右键菜单触发方式。

虚拟触发

支持虚拟元素触发,适用于触发元素和展示内容分离的场景。

嵌套操作

可以在 Popover 中嵌套其他组件和操作。

自动关闭

设置自动关闭时间,弹出框会在指定时间后自动隐藏。

API

Popover Props

参数说明类型可选值默认值
title标题文本,也可以通过 slot#title 传入string
content显示的内容,也可以通过 slot#content 传入string
placementPopover 的出现位置stringtop/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-endbottom
effect默认提供的主题stringdark/lightlight
visible / v-model:visible状态是否可见booleanfalse
disabledPopover 是否可用booleanfalse
show-arrow是否显示 Popover 箭头booleantrue
trigger触发方式stringhover/focus/click/manual/contextmenuclick
show-after延迟出现,单位毫秒number0
hide-after延迟关闭,单位毫秒number200
popper-class为 Popover 的 popper 添加类名string
offset出现位置的偏移量number4
raw-content是否将 content 作为 HTML 字符串处理booleanfalse
enterable鼠标是否可进入到 popover 中booleantrue
hide-on-click-outside是否在点击外部时隐藏booleantrue
close-on-esc是否支持 ESC 键关闭booleantrue
aria-label屏幕阅读器标签string
width弹层宽度numberstring
transition定义渐变动画stringccui-popover-fade
auto-close自动关闭时间,单位毫秒number0
tabindexPopover 组件的 tabindexnumberstring
teleported是否将 popover 插入至 body 元素booleantrue
persistent是否持久化booleantrue
virtual-triggering是否启用虚拟触发器booleanfalse
virtual-ref虚拟触发器的参照元素HTMLElement
trigger-keys键盘触发按键string[]['Enter', 'Space']

Popover Events

事件名说明回调参数
before-show显示前触发
show显示时触发
before-hide隐藏前触发
hide隐藏时触发
update:visible状态变更时触发visible
before-enter显示动画播放前触发
after-enter显示动画播放后触发
before-leave隐藏动画播放前触发
after-leave隐藏动画播放后触发

Popover Slots

插槽名说明
defaultPopover 触发 & 引用的元素
title自定义标题
content自定义内容

Popover Exposes

方法名说明类型
hide隐藏弹出框() => void

Released under the MIT License.