Skip to content

Popover 弹出框

通用的悬浮信息容器,比 Tooltip 更强大,可嵌入复杂内容和操作(按钮、表单等)。

基础用法

使用 content 属性设置弹出内容,trigger 默认为 click

标题与内容

通过 titlecontent 属性设置标题和内容。

触发方式

支持 clickhoverfocuscontextmenu 四种触发方式。

弹出位置

支持 12 个方向的弹出位置。

自定义内容

通过 content 插槽可以嵌入任意内容(按钮、表单等)。

v-model 控制显隐

通过 v-model:visible 双向绑定控制 Popover 的显示与隐藏。

Popover API

Props

参数说明类型默认值
title弹出框标题string''
content弹出框内容文本string''
visible是否显示 (v-model:visible)booleanfalse
placement弹出位置'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end''bottom'
trigger触发方式'hover' | 'click' | 'focus' | 'contextmenu''click'
showDelay显示延迟(毫秒,仅 hover)number100
hideDelay隐藏延迟(毫秒,仅 hover)number100
disabled是否禁用booleanfalse
showArrow是否显示箭头booleantrue
popperClass自定义类名string''
width弹出框宽度(px 或 CSS 字符串)number | string-
minWidth弹出框最小宽度(px 或 CSS 字符串)number | string-
transition过渡动画名称string'zc-popover'
offset触发元素与弹出框之间的间距(px)number8
hideAfterClickOutside点击外部是否自动关闭booleantrue

Events

事件名说明回调参数
update:visible显隐状态变化时触发
show显示时触发
hide隐藏时触发
after-enter显示动画结束后触发
after-leave隐藏动画结束后触发

Slots

插槽名说明
default触发元素
title标题内容
content弹出内容(支持任意 HTML/Vue 组件)

Exposed Methods

方法名说明参数
show()手动显示弹出框
hide()手动隐藏弹出框
toggle()切换显示/隐藏
updatePosition()手动更新弹出框位置

基于 MIT 许可发布