Popover 弹出框

展示位置

Popover 弹出框提供 9 种展示位置。

使用 content 属性来设置悬停时显示的信息。 由 placement 属性决定 Popover 弹出框的位置。 该属性值格式为:[方向]-[对齐位置],可供选择的四个方向分别是topleftrightbottom,可供选择的三种对齐方式分别是startendnull,默认的对齐方式为null。 以 placement="left-end" 为例,Popover 弹出框会显示在悬停元素的左侧,且提示信息的底部与悬停元素的底部对齐。

基础用法

Popover 是在 ElTooltip 基础上开发出来的。 因此对于重复属性,请参考 Tooltip 的文档,在此文档中不做详尽解释。

trigger 属性被用来决定 popover 的触发方式,支持的触发方式: hoverclickfocuscontextmenu。 如果你想手动控制它,可以设置 :visible 属性。

虚拟触发

Like Tooltip, Popover can be triggered by virtual elements, if your use case includes separate the triggering element and the content element, you should definitely use the mechanism, normally we use #reference to place our triggering element, with virtual-ref API you can set your triggering element anywhere you like, but notice that the triggering element should be an element that accepts mouse and keyboard event.

WARNING

v-popover 将被废弃,请使用 virtual-ref 作为替代。

内容可扩展

可以在 Popover 中嵌套其它组件, 以下为嵌套表格的例子。

利用插槽取代 content 属性

嵌套操作

当然,你还可以嵌套操作, 它比使用dialog更加轻量。

指令

您可以使用指令性方式弹出窗口,但这种方法不再推荐 ,因为这使得应用程序变得复杂, 您可以参考虚拟触发来实现一样的效果。

API

Attributes

属性名说明类型Default
triggerpopover 触发方式,在受控模式下无效。enum / arrayhover
trigger-keys 2.9.8当通过鼠标点击使触发元素获得焦点时,可以定义一组键盘按键代码,通过键盘控制气泡框的显示,在受控模式下无效。Array['Enter','Space']
title标题string
effectTooltip 主题,Element Plus 内置了 dark / light 两种主题enum / stringlight
content显示的内容,也可以通过写入默认 slot 修改显示内容string''
width宽度string / number150
placement出现位置enumbottom
disabledPopover 是否可用booleanfalse
visible / v-model:visiblePopover 是否显示boolean / nullnull
offset浮层偏移量, Popover 是在 Tooltip,基础上开发的, Popover的 offset 是 undefined, 但Tooltip 的 offset 是12numberundefined
transition定义渐变动画,默认是 el-fade-in-linearstring
show-arrow是否显示 Tooltip 箭头, 欲了解更多信息,请参考 ElPopperbooleantrue
popper-optionspopper.js 的参数object{modifiers: [{name: 'computeStyles',options: {gpuAcceleration: false}}]}
popper-class为 popper 添加类名string
popper-style为 popper 自定义样式string / object
show-after延迟显示时间(以毫秒为单位),在受控模式下无效。number0
hide-after消失延迟时间(以毫秒为单位),在受控模式下无效。number200
auto-close隐藏提示框的超时时间(以毫秒为单位),在受控模式下无效。number0
tabindexPopover 组件的 tabindexnumber / string0
teleported是否将 popover 的下拉列表插入至 body 元素booleantrue
append-to 2.8.4指示 Tooltip 的内容将附加在哪一个网页元素上CSSSelector / HTMLElementbody
persistent当 popover 组件长时间不触发且 persistent 属性设置为 false 时, popover 将会被删除booleantrue
virtual-triggering是否启用虚拟触发器boolean
virtual-ref代表 tooltip 所要附加的参照元素HTMLElement
tooltip继承自 Tooltip 的所有属性:::

Slots

插槽名说明Type
default弹出框的内容,2.13.4 及之后版本可以接收 hide 参数。object
reference触发弹出框的 HTML 元素,只接受单个根元素。-

Events

事件名说明类型
show显示时触发Function
before-enter显示动画播放前触发Function
after-enter显示动画播放完毕后触发Function
hide隐藏时触发Function
before-leave隐藏动画播放前触发Function
after-leave隐藏动画播放完毕后触发Function

Exposes

名称详情Type
hide隐藏 popoverFunction

源代码

组件样式文档

贡献者