2016-07-27 14:15:02 +08:00
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
visible2: false,
|
|
|
|
|
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 弄'
|
|
|
|
|
}],
|
|
|
|
|
gridData2: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$info: true
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄',
|
|
|
|
|
$positive: true
|
|
|
|
|
}],
|
|
|
|
|
gridData3: [{
|
|
|
|
|
tag: '家',
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '公司',
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '公司',
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '家',
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '公司',
|
|
|
|
|
date: '2016-05-08',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '家',
|
|
|
|
|
date: '2016-05-06',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
tag: '公司',
|
|
|
|
|
date: '2016-05-07',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
2018-03-07 12:24:34 +08:00
|
|
|
|
}]
|
2016-07-27 14:15:02 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.demo-box.demo-popover {
|
|
|
|
|
.el-popover + .el-popover {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
.el-input {
|
|
|
|
|
width: 360px;
|
|
|
|
|
}
|
2016-09-08 11:21:17 +08:00
|
|
|
|
.el-button {
|
2016-07-27 14:15:02 +08:00
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
## Popover 弹出框
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 基础用法
|
|
|
|
|
Popover 的属性与 Tooltip 很类似,它们都是基于`Vue-popper`开发的,因此对于重复属性,请参考 Tooltip 的文档,在此文档中不做详尽解释。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2018-04-27 12:27:41 +08:00
|
|
|
|
:::demo `trigger`属性用于设置何时触发 Popover,支持四种触发方式:`hover`,`click`,`focus` 和 `manual`。对于触发 Popover 的元素,有两种写法:使用 `slot="reference"` 的具名插槽,或使用自定义指令`v-popover`指向 Popover 的索引`ref`。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="top-start"
|
|
|
|
|
title="标题"
|
|
|
|
|
width="200"
|
|
|
|
|
trigger="hover"
|
2016-11-23 16:47:04 +08:00
|
|
|
|
content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
|
2018-04-27 12:27:41 +08:00
|
|
|
|
<el-button slot="reference">hover 激活</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="bottom"
|
|
|
|
|
title="标题"
|
|
|
|
|
width="200"
|
|
|
|
|
trigger="click"
|
2016-11-23 16:47:04 +08:00
|
|
|
|
content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
|
2018-04-27 12:27:41 +08:00
|
|
|
|
<el-button slot="reference">click 激活</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
|
|
|
|
<el-popover
|
2018-04-27 12:27:41 +08:00
|
|
|
|
ref="popover"
|
2016-07-27 14:15:02 +08:00
|
|
|
|
placement="right"
|
|
|
|
|
title="标题"
|
|
|
|
|
width="200"
|
|
|
|
|
trigger="focus"
|
2016-11-23 16:47:04 +08:00
|
|
|
|
content="这是一段内容,这是一段内容,这是一段内容,这是一段内容。">
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-popover>
|
2018-04-27 12:27:41 +08:00
|
|
|
|
<el-button v-popover:popover>focus 激活</el-button>
|
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-26 18:34:54 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 嵌套信息
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-09-12 21:04:20 +08:00
|
|
|
|
可以在 Popover 中嵌套多种类型信息,以下为嵌套表格的例子。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
:::demo 利用分发取代`content`属性
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="right"
|
|
|
|
|
width="400"
|
|
|
|
|
trigger="click">
|
|
|
|
|
<el-table :data="gridData">
|
|
|
|
|
<el-table-column width="150" property="date" label="日期"></el-table-column>
|
|
|
|
|
<el-table-column width="100" property="name" label="姓名"></el-table-column>
|
|
|
|
|
<el-table-column width="300" property="address" label="地址"></el-table-column>
|
|
|
|
|
</el-table>
|
2018-04-27 12:27:41 +08:00
|
|
|
|
<el-button slot="reference">click 激活</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
2016-11-14 18:10:52 +08:00
|
|
|
|
<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>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-26 18:34:54 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### 嵌套操作
|
2016-08-19 14:45:08 +08:00
|
|
|
|
|
|
|
|
|
当然,你还可以嵌套操作,这相比 Dialog 更为轻量:
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
:::demo
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```html
|
|
|
|
|
<el-popover
|
|
|
|
|
placement="top"
|
|
|
|
|
width="160"
|
2016-09-02 19:32:17 +08:00
|
|
|
|
v-model="visible2">
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<p>这是一段内容这是一段内容确定删除吗?</p>
|
|
|
|
|
<div style="text-align: right; margin: 0">
|
2016-11-20 22:39:33 +08:00
|
|
|
|
<el-button size="mini" type="text" @click="visible2 = false">取消</el-button>
|
|
|
|
|
<el-button type="primary" size="mini" @click="visible2 = false">确定</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</div>
|
2018-04-27 12:27:41 +08:00
|
|
|
|
<el-button slot="reference">删除</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
2016-11-14 18:10:52 +08:00
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
visible2: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
```
|
2016-08-26 18:34:54 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### Attributes
|
2016-07-27 14:15:02 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
|
|
|
|--------------------|----------------------------------------------------------|-------------------|-------------|--------|
|
2016-11-16 13:52:43 +08:00
|
|
|
|
| trigger | 触发方式 | String | click/focus/hover/manual | click |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| title | 标题 | String | — | — |
|
2016-09-02 14:51:01 +08:00
|
|
|
|
| content | 显示的内容,也可以通过 `slot` 传入 DOM | String | — | — |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| width | 宽度 | String, Number | — | 最小宽度 150px |
|
2016-09-02 14:51:01 +08:00
|
|
|
|
| placement | 出现位置 | String | top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end | bottom |
|
2017-01-06 16:15:11 +08:00
|
|
|
|
| disabled | Popover 是否可用 | Boolean | — | false |
|
2016-09-02 19:32:17 +08:00
|
|
|
|
| value(v-model) | 状态是否可见 | Boolean | — | false |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| offset | 出现位置的偏移量 | Number | — | 0 |
|
2016-09-02 14:51:01 +08:00
|
|
|
|
| transition | 定义渐变动画 | String | — | fade-in-linear |
|
2016-09-02 13:56:47 +08:00
|
|
|
|
| visible-arrow | 是否显示 Tooltip 箭头,更多参数可见[Vue-popper](https://github.com/element-component/vue-popper) | Boolean | — | true |
|
2017-04-06 18:45:40 +08:00
|
|
|
|
| popper-options | [popper.js](https://popper.js.org/documentation.html) 的参数 | Object | 参考 [popper.js](https://popper.js.org/documentation.html) 文档 | `{ boundariesElement: 'body', gpuAcceleration: false }` |
|
2016-12-29 20:53:33 +08:00
|
|
|
|
| popper-class | 为 popper 添加类名 | String | — | — |
|
2017-07-15 17:14:40 +08:00
|
|
|
|
| open-delay | 触发方式为 hover 时的显示延迟,单位为毫秒 | Number | — | — |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-26 18:34:54 +08:00
|
|
|
|
### Slot
|
2017-07-15 17:14:40 +08:00
|
|
|
|
| 参数 | 说明 |
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|--- | ---|
|
2016-10-09 09:02:16 +08:00
|
|
|
|
| — | Popover 内嵌 HTML 文本 |
|
|
|
|
|
| reference | 触发 Popover 显示的 HTML 元素 |
|
2016-11-27 18:07:24 +08:00
|
|
|
|
|
|
|
|
|
### Events
|
|
|
|
|
| 事件名称 | 说明 | 回调参数 |
|
|
|
|
|
|---------|--------|---------|
|
|
|
|
|
| show | 显示时触发 | — |
|
2018-03-07 12:24:34 +08:00
|
|
|
|
| after-enter | 显示动画播放完毕后触发 | — |
|
2016-11-27 18:07:24 +08:00
|
|
|
|
| hide | 隐藏时触发 | — |
|
2018-03-07 12:24:34 +08:00
|
|
|
|
| after-leave | 隐藏动画播放完毕后触发 | — |
|