refactor(Icon): use setup

This commit is contained in:
chenjiahan 2020-08-23 13:09:52 +08:00
parent 1b96a45d0b
commit 785047754b

View File

@ -24,25 +24,24 @@ export default createComponent({
}, },
}, },
render() { setup(props, { slots }) {
const { name } = this; return () => {
const imageIcon = isImage(name); const { tag, dot, name, size, badge, color, classPrefix } = props;
const isImageIcon = isImage(name);
return ( return (
<this.tag <tag
class={[ class={[classPrefix, isImageIcon ? '' : `${classPrefix}-${name}`]}
this.classPrefix, style={{
imageIcon ? '' : `${this.classPrefix}-${name}`, color,
]} fontSize: addUnit(size),
style={{ }}
color: this.color, >
fontSize: addUnit(this.size), {slots.default?.()}
}} {isImageIcon && <img class={bem('image')} src={name} />}
> <Badge dot={dot} badge={badge} />
{this.$slots.default?.()} </tag>
{imageIcon && <img class={bem('image')} src={name} />} );
<Badge dot={this.dot} badge={this.badge} /> };
</this.tag>
);
}, },
}); });