feat(Badge): add show-zero prop (#8381)

This commit is contained in:
neverland
2021-03-19 09:59:51 +08:00
committed by GitHub
parent 2c1f412f8e
commit fa5c8cd0b4
4 changed files with 26 additions and 2 deletions
+11 -2
View File
@@ -17,11 +17,20 @@ export default defineComponent({
type: String as PropType<keyof HTMLElementTagNameMap>,
default: 'div',
},
showZero: {
type: Boolean,
default: true,
},
},
setup(props, { slots }) {
const hasContent = () =>
!!(slots.content || (isDef(props.content) && props.content !== ''));
const hasContent = () => {
if (slots.content) {
return true;
}
const { content, showZero } = props;
return isDef(content) && content !== '' && (showZero || content !== 0);
};
const renderContent = () => {
const { dot, max, content } = props;