UNPKG

zk-desktop-ui

Version:

ZKTeco UI Components

148 lines (121 loc) 4.81 kB
## Popover 弹出框 ### 基础用法 Popover 的属性与 Tooltip 很类似,它们都是基于`Vue-popper`开发的,因此对于重复属性,请参考 Tooltip 的文档,在此文档中不做详尽解释。 > demo 设置索引`ref`,在按钮中,我们注册了自定义指令`v-popover`,指向索引ID。`trigger`属性用于设置何时触发 Popover ,提供三种触发方式:`hover`, `click` 和 `focus`。第二种用法通过 `slot` 指定 reference。 ```html <zk-popover ref="popover1" placement="top-start" title="标题" width="200" trigger="hover" content="这是一段容,这是一段容,这是一段容,这是一段容。"> </zk-popover> <zk-popover ref="popover2" placement="bottom" title="标题" width="200" trigger="click" content="这是一段容,这是一段容,这是一段容,这是一段容。"> </zk-popover> <zk-button v-popover:popover1>hover 激活</zk-button> <zk-button v-popover:popover2>click 激活</zk-button> <zk-popover placement="right" title="标题" width="200" trigger="focus" content="这是一段容,这是一段容,这是一段容,这是一段容。"> <zk-button slot="reference">focus 激活</zk-button> </zk-popover> ``` ### 嵌套信息 可以在 Popover 中嵌套多种类型信息,以下为嵌套表格的例子。 > demo 利用分发取代`content`属性 ```html <zk-popover ref="popover4" placement="right" width="400" trigger="click"> <zk-table :data="gridData"> <zk-table-column width="150" property="date" label="日期"></zk-table-column> <zk-table-column width="100" property="name" label="姓名"></zk-table-column> <zk-table-column width="300" property="address" label="地址"></zk-table-column> </zk-table> </zk-popover> <zk-button v-popover:popover4>click 激活</zk-button> <script> export default { data() { return { gridData: [{ date: '2016-05-02', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' }, { date: '2016-05-04', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' }, { date: '2016-05-01', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' }, { date: '2016-05-03', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' }] }; } }; </script> ``` ### 嵌套操作 当然,你还可以嵌套操作,这相比 Dialog 更为轻量: > demo ```html <zk-popover ref="popover5" placement="top" width="160" v-model="visible2"> <p>这是一段内容这是一段内容确定删除吗?</p> <div style="text-align: right; margin: 0"> <zk-button size="mini" type="text" @click.native="visible2 = false">取消</zk-button> <zk-button type="primary" size="mini" @click.native="visible2 = false">确定</zk-button> </div> </zk-popover> <zk-button v-popover:popover5>删除</zk-button> <script> export default { data() { return { visible2: false, }; } } </script> ``` ### 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 | | value(v-model) | 状态是否可见 | Boolean | — | false | | offset | 出现位置的偏移量 | Number | — | 0 | | transition | 定义渐变动画 | String | — | fade-in-linear | | visible-arrow | 是否显示 Tooltip 箭头,更多参数可见[Vue-popper](https://github.com/element-component/vue-popper) | Boolean | — | true | | options | [popper.js](https://popper.js.org/documentation.html) 的参数 | Object | 参考 [popper.js](https://popper.js.org/documentation.html) 文档 | `{ boundariesElement: 'body', gpuAcceleration: false }` | | popper-class | 为 popper 添加类名 | String | - | -| ### Slot | 参数 | 说明 | |--- | ---| | — | Popover 内嵌 HTML 文本 | | reference | 触发 Popover 显示的 HTML 元素 |