Commit d3905b354895257eed6c82f9aa89a87d936fe149

Authored by xiaofengsha
1 parent 82278172

Badge 组件增加 showZero 属性

Showing 1 changed file with 12 additions and 3 deletions   Show diff stats
src/components/badge/badge.vue
... ... @@ -5,7 +5,7 @@
5 5 </span>
6 6 <span v-else :class="classes" ref="badge">
7 7 <slot></slot>
8   - <sup v-if="count" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
  8 + <sup v-if="hasCount" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
9 9 </span>
10 10 </template>
11 11 <script>
... ... @@ -23,7 +23,11 @@
23 23 type: [Number, String],
24 24 default: 99
25 25 },
26   - className: String
  26 + className: String,
  27 + showZero: {
  28 + type: Boolean,
  29 + default: false
  30 + }
27 31 },
28 32 computed: {
29 33 classes () {
... ... @@ -60,7 +64,12 @@
60 64 }
61 65 }
62 66  
63   - return status;
  67 + return status || this.showZero;
  68 + },
  69 + hasCount() {
  70 + if(this.count) return true;
  71 + if(this.showZero && parseInt(this.count) === 0) return true;
  72 + else return false;
64 73 },
65 74 alone () {
66 75 return this.$slots.default === undefined;
... ...