Popover: add disabled feature, close #2221

pull/2256/head
qingwei.li 2017-01-06 16:15:11 +08:00
parent 29c99dba59
commit d3a9cf8f21
5 changed files with 10 additions and 7 deletions

View File

@ -212,6 +212,7 @@ Of course, you can nest other operations. It's more light-weight than using a di
| content | popover content, can be replaced with a default `slot` | string | — | — | | content | popover content, can be replaced with a default `slot` | string | — | — |
| width | popover width | string, number | — | Min width 150px | | width | popover width | string, number | — | Min width 150px |
| placement | popover placement | string | top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end | bottom | | placement | popover placement | string | top/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-end | bottom |
| disabled | whether Popover is disabled | boolean | — | false |
| value(v-model) | whether popover is visible | Boolean | — | false | | value(v-model) | whether popover is visible | Boolean | — | false |
| offset | popover offset | number | — | 0 | | offset | popover offset | number | — | 0 |
| transition | popover transition animation | string | — | fade-in-linear | | transition | popover transition animation | string | — | fade-in-linear |

View File

@ -113,12 +113,12 @@ Tooltip has 9 placements.
.item { .item {
margin: 4px; margin: 4px;
} }
.left .el-tooltip__popper, .left .el-tooltip__popper,
.right .el-tooltip__popper { .right .el-tooltip__popper {
padding: 8px 10px; padding: 8px 10px;
} }
.el-button { .el-button {
width: 110px; width: 110px;
} }
@ -145,7 +145,7 @@ Tooltip has two themes: `dark` and `light`。
### More Content ### More Content
Display multiple lines of text and set their format. Display multiple lines of text and set their format.
:::demo Override attribute `content` of `el-tooltip` by adding a slot named `content`. :::demo Override attribute `content` of `el-tooltip` by adding a slot named `content`.
```html ```html
@ -170,7 +170,7 @@ In fact, Tooltip is an extension based on [Vue-popper](https://github.com/elemen
```html ```html
<template> <template>
<el-tooltip :disabled="disabled" content="click to close tooltip function" placement="bottom" effect="light"> <el-tooltip :disabled="disabled" content="click to close tooltip function" placement="bottom" effect="light">
<el-button @click="disabled=true">click to close tooltip function</el-button> <el-button @click="disabled = !disabled">click to {{disabled ? 'active' : 'close'}} tooltip function</el-button>
</el-tooltip> </el-tooltip>
</template> </template>

View File

@ -239,6 +239,7 @@ Popover 的属性与 Tooltip 很类似,它们都是基于`Vue-popper`开发的
| content | 显示的内容,也可以通过 `slot` 传入 DOM | String | — | — | | content | 显示的内容,也可以通过 `slot` 传入 DOM | String | — | — |
| width | 宽度 | String, Number | — | 最小宽度 150px | | 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 | | 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 | | value(v-model) | 状态是否可见 | Boolean | — | false |
| offset | 出现位置的偏移量 | Number | — | 0 | | offset | 出现位置的偏移量 | Number | — | 0 |
| transition | 定义渐变动画 | String | — | fade-in-linear | | transition | 定义渐变动画 | String | — | fade-in-linear |

View File

@ -134,7 +134,7 @@
.item { .item {
margin: 4px; margin: 4px;
} }
.left .el-tooltip__popper, .left .el-tooltip__popper,
.right .el-tooltip__popper { .right .el-tooltip__popper {
padding: 8px 10px; padding: 8px 10px;
@ -189,7 +189,7 @@ Tooltip 组件提供了两个不同的主题:`dark`和`light`。
```html ```html
<template> <template>
<el-tooltip :disabled="disabled" content="点击关闭 tooltip 功能" placement="bottom" effect="light"> <el-tooltip :disabled="disabled" content="点击关闭 tooltip 功能" placement="bottom" effect="light">
<el-button @click="disabled = true">点击关闭 tooltip 功能</el-button> <el-button @click="disabled = !disabled">点击{{disabled ? '开启' : '关闭'}} tooltip 功能</el-button>
</el-tooltip> </el-tooltip>
</template> </template>
``` ```

View File

@ -5,7 +5,7 @@
class="el-popover" class="el-popover"
:class="[popperClass]" :class="[popperClass]"
ref="popper" ref="popper"
v-show="showPopper" v-show="!disabled && showPopper"
:style="{ width: width + 'px' }"> :style="{ width: width + 'px' }">
<div class="el-popover__title" v-if="title" v-text="title"></div> <div class="el-popover__title" v-if="title" v-text="title"></div>
<slot>{{ content }}</slot> <slot>{{ content }}</slot>
@ -31,6 +31,7 @@ export default {
validator: value => ['click', 'focus', 'hover', 'manual'].indexOf(value) > -1 validator: value => ['click', 'focus', 'hover', 'manual'].indexOf(value) > -1
}, },
title: String, title: String,
disabled: Boolean,
content: String, content: String,
reference: {}, reference: {},
popperClass: String, popperClass: String,