fix(Grid): info、dot prop not work when use icon slot (#4902)
This commit is contained in:
+29
-12
@@ -2,6 +2,7 @@ import { createNamespace, addUnit } from '../utils';
|
||||
import { BORDER } from '../utils/constant';
|
||||
import { ChildrenMixin } from '../mixins/relation';
|
||||
import { route, routeProps } from '../utils/router';
|
||||
import Info from '../info';
|
||||
import Icon from '../icon';
|
||||
|
||||
const [createComponent, bem] = createNamespace('grid-item');
|
||||
@@ -61,7 +62,32 @@ export default createComponent({
|
||||
route(this.$router, this);
|
||||
},
|
||||
|
||||
renderContent() {
|
||||
genIcon() {
|
||||
const iconSlot = this.slots('icon');
|
||||
|
||||
if (iconSlot) {
|
||||
return (
|
||||
<div class={bem('icon-wrapper')}>
|
||||
{iconSlot}
|
||||
<Info dot={this.dot} info={this.info} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.icon) {
|
||||
return (
|
||||
<Icon
|
||||
name={this.icon}
|
||||
dot={this.dot}
|
||||
info={this.info}
|
||||
size={this.parent.iconSize}
|
||||
class={bem('icon')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
genContent() {
|
||||
const slot = this.slots();
|
||||
|
||||
if (slot) {
|
||||
@@ -69,16 +95,7 @@ export default createComponent({
|
||||
}
|
||||
|
||||
return [
|
||||
this.slots('icon') ||
|
||||
(this.icon && (
|
||||
<Icon
|
||||
name={this.icon}
|
||||
dot={this.dot}
|
||||
info={this.info}
|
||||
size={this.parent.iconSize}
|
||||
class={bem('icon')}
|
||||
/>
|
||||
)),
|
||||
this.genIcon(),
|
||||
this.slots('text') || (this.text && <span class={bem('text')}>{this.text}</span>)
|
||||
];
|
||||
}
|
||||
@@ -104,7 +121,7 @@ export default createComponent({
|
||||
]}
|
||||
onClick={this.onClick}
|
||||
>
|
||||
{this.renderContent()}
|
||||
{this.genContent()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
font-size: @grid-item-icon-size;
|
||||
}
|
||||
|
||||
&__icon-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
&__text {
|
||||
color: @grid-item-text-color;
|
||||
font-size: @grid-item-text-font-size;
|
||||
|
||||
Reference in New Issue
Block a user