Badge 组件增加 showZero 属性
This commit is contained in:
parent
82278172bb
commit
d3905b3548
1 changed files with 12 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span v-else :class="classes" ref="badge">
|
<span v-else :class="classes" ref="badge">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<sup v-if="count" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
|
<sup v-if="hasCount" :class="countClasses" v-show="badge">{{ finalCount }}</sup>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -23,7 +23,11 @@
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: 99
|
default: 99
|
||||||
},
|
},
|
||||||
className: String
|
className: String,
|
||||||
|
showZero: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
|
@ -60,7 +64,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status || this.showZero;
|
||||||
|
},
|
||||||
|
hasCount() {
|
||||||
|
if(this.count) return true;
|
||||||
|
if(this.showZero && parseInt(this.count) === 0) return true;
|
||||||
|
else return false;
|
||||||
},
|
},
|
||||||
alone () {
|
alone () {
|
||||||
return this.$slots.default === undefined;
|
return this.$slots.default === undefined;
|
||||||
|
|
Loading…
Add table
Reference in a new issue