Badge: add hidden prop, close #2042 (#2050)

This commit is contained in:
cinwell.li 2016-12-29 10:41:41 +08:00 committed by FuryBean
parent 47e75ad051
commit c639474fcc
3 changed files with 13 additions and 7 deletions

View File

@ -134,4 +134,5 @@ Use a red dot to mark content that needs to be noticed.
|------------- |---------------- |---------------- |---------------------- |-------- | |------------- |---------------- |---------------- |---------------------- |-------- |
| value | display value | string, number | — | — | | value | display value | string, number | — | — |
| max | maximum value, shows '{max}+' when exceeded. Only works if `value` is a `Number` | number | — | — | | max | maximum value, shows '{max}+' when exceeded. Only works if `value` is a `Number` | number | — | — |
| is-dot | if a little dot is displayed | boolean | — | false | | is-dot | if a little dot is displayed | boolean | — | false |
| hidden | hidden badge | boolean | - | false |

View File

@ -137,3 +137,4 @@
| value | 显示值 | string, number | — | — | | value | 显示值 | string, number | — | — |
| max | 最大值,超过最大值会显示 '{max}+',要求 value 是 Number 类型 | number | — | — | | max | 最大值,超过最大值会显示 '{max}+',要求 value 是 Number 类型 | number | — | — |
| is-dot | 小圆点 | boolean | — | false | | is-dot | 小圆点 | boolean | — | false |
| hidden | 隐藏 badge | boolean | - | false |

View File

@ -1,11 +1,14 @@
<template> <template>
<div class="el-badge"> <div class="el-badge">
<slot></slot> <slot></slot>
<sup <transition name="el-zoom-in-center">
v-text="content" <sup
class="el-badge__content" v-show="!hidden"
:class="{ 'is-fixed': $slots.default, 'is-dot': isDot }"> v-text="content"
</sup> class="el-badge__content"
:class="{ 'is-fixed': $slots.default, 'is-dot': isDot }">
</sup>
</transition>
</div> </div>
</template> </template>
@ -16,7 +19,8 @@ export default {
props: { props: {
value: {}, value: {},
max: Number, max: Number,
isDot: Boolean isDot: Boolean,
hidden: Boolean
}, },
computed: { computed: {