mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-26 00:09:15 +08:00
chore: remove legacy badge
This commit is contained in:
parent
648906fff7
commit
2cb5e5e566
@ -1,69 +0,0 @@
|
|||||||
import { isDef, createNamespace } from '../utils';
|
|
||||||
import { isNumeric } from '../utils/validate/number';
|
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('badge');
|
|
||||||
|
|
||||||
export default createComponent({
|
|
||||||
props: {
|
|
||||||
dot: Boolean,
|
|
||||||
max: [Number, String],
|
|
||||||
color: String,
|
|
||||||
content: [Number, String],
|
|
||||||
tag: {
|
|
||||||
type: String,
|
|
||||||
default: 'div',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
hasContent() {
|
|
||||||
return !!(
|
|
||||||
this.$scopedSlots.content ||
|
|
||||||
(isDef(this.content) && this.content !== '')
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderContent() {
|
|
||||||
const { dot, max, content } = this;
|
|
||||||
|
|
||||||
if (!dot && this.hasContent()) {
|
|
||||||
if (this.$scopedSlots.content) {
|
|
||||||
return this.$scopedSlots.content();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isDef(max) && isNumeric(content) && +content > max) {
|
|
||||||
return `${max}+`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
renderBadge() {
|
|
||||||
if (this.hasContent() || this.dot) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
class={bem({ dot: this.dot, fixed: !!this.$scopedSlots.default })}
|
|
||||||
style={{ background: this.color }}
|
|
||||||
>
|
|
||||||
{this.renderContent()}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.$scopedSlots.default) {
|
|
||||||
const { tag } = this;
|
|
||||||
return (
|
|
||||||
<tag class={bem('wrapper')}>
|
|
||||||
{this.$scopedSlots.default()}
|
|
||||||
{this.renderBadge()}
|
|
||||||
</tag>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.renderBadge();
|
|
||||||
},
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user