# Popover 弹出框
# 基础用法
- Popover 的属性与 Tooltip 很类似,它们都是基于
Vue-popper开发的,因此对于重复属性,请参考 Tooltip 的文档,在此文档中不做详尽解释。 trigger属性用于设置何时触发 Popover,支持四种触发方式:hover,click,focus和manual。对于触发 Popover 的元素,有两种写法:使用slot="reference"的具名插槽,或使用自定义指令v-popover指向 Popover 的索引ref。- 对
width进行了改进,如果传输的是number或者string值为50那么会自动拼上px单位。如果携带了px%emrem的字符串则是直接使用
Copy
# 嵌套信息
- 可以在 Popover 中嵌套多种类型信息,以下为嵌套表格的例子。
- 利用分发取代
content属性
Copy
# 嵌套操作
将
show-aciton值为true才会显示操作栏,默认会展示取消和确定当前您也可以定义
slot的name为aciton。自定义插槽您也可以通过
confirmText设定确定文本,通过cancelText设定取消文本。通过showConfirm和showCancel分别指定是否显示默认都为true您可以通过指定
:beforeConfirm来设置确定前置操作,通过:beforeCancel设定取消前置操作。function返回false则不会自动关闭通过设置
type属性来决定icon,也可以通过icon属性来自定义
这是一段内容确定删除吗?
这是一段内容确定删除吗?
Copy
# 指令触发
- 通过指令的方式我们也可以轻松的实现,
v-db_popover的:后参数为触发条件,值必须是一个Object。通过修改原型的方式,他可以传入当前该组件所有能实现的功能。
Copy
# Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| trigger | 触发方式 | String | click/focus/hover/manual | click |
| title | 标题 | String | — | — |
| content | 显示的内容,也可以通过 slot 传入 DOM | String | — | — |
| width | 宽度 | String, Number | — | 最小宽度 150px |
| placement | 出现位置 | String | top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end | bottom |
| disabled | Popover 是否可用 | Boolean | — | false |
| value / v-model | 状态是否可见 | Boolean | — | false |
| offset | 出现位置的偏移量 | Number | — | 0 |
| transition | 定义渐变动画 | String | — | fade-in-linear |
| visible-arrow | 是否显示 Tooltip 箭头,更多参数可见Vue-popper (opens new window) | Boolean | — | true |
| popper-options | popper.js (opens new window) 的参数 | Object | 参考 popper.js (opens new window) 文档 | { boundariesElement: 'body', gpuAcceleration: false } |
| popper-class | 为 popper 添加类名 | String | — | — |
| open-delay | 触发方式为 hover 时的显示延迟,单位为毫秒 | Number | — | — |
| close-delay | 触发方式为 hover 时的隐藏延迟,单位为毫秒 | number | — | 200 |
| tabindex | Popover 组件的 tabindex (opens new window) | number | — | 0 |
| confirmText | 确定文本 | String | — | 确定 |
| cancelText | 取消文本 | String | — | 取消 |
| showConfirm | 显示确定 | Boolean | — | true |
| showCancel | 显示取消 | Boolean | — | true |
| beforeConfirm | 确定按钮前置触发 | Function | — | - |
| beforeCancel | 取消按钮前置触发 | |||
| Function | — | - | ||
| customContent | 自定义内容样式 | Boolean | — | false |
| type | 显示类型 | String | success/error/warning/primary | - |
| icon | 显示图标 | String | — | - |
| maxNumber | 最大内容隐藏 | Number | — | - |
| show | 显示时触发 | Function | — | - |
| after-enter | 显示动画播放完毕后触发 | Function | — | - |
| hide | 隐藏时触发 | Function | — | - |
| after-leave | 隐藏动画播放完毕后触发 | Function | — | - |
| cancel | 取消按钮触发 | Function | — | - |
| confirm | 确定按钮触发 | Function | — | - |
| confirmType | 设置确定按钮类型 | text | — | - |
| cancelType | 设置取消按钮类型 | text | — | - |
# Slot
| 参数 | 说明 |
|---|---|
| — | Popover 内嵌 HTML 文本 |
| reference | 触发 Popover 显示的 HTML 元素 |
| action | 操作栏插槽 |
# Events
| 事件名称 | 说明 | 回调参数 |
|---|---|---|
| show | 显示时触发 | — |
| after-enter | 显示动画播放完毕后触发 | — |
| hide | 隐藏时触发 | — |
| after-leave | 隐藏动画播放完毕后触发 | — |