diff --git a/src/grid-item/index.js b/src/grid-item/index.js
index 5dad92519..4a0de1011 100644
--- a/src/grid-item/index.js
+++ b/src/grid-item/index.js
@@ -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 (
+
+ {iconSlot}
+
+
+ );
+ }
+
+ if (this.icon) {
+ return (
+
+ );
+ }
+ },
+
+ genContent() {
const slot = this.slots();
if (slot) {
@@ -69,16 +95,7 @@ export default createComponent({
}
return [
- this.slots('icon') ||
- (this.icon && (
-
- )),
+ this.genIcon(),
this.slots('text') || (this.text && {this.text})
];
}
@@ -104,7 +121,7 @@ export default createComponent({
]}
onClick={this.onClick}
>
- {this.renderContent()}
+ {this.genContent()}
);
diff --git a/src/grid-item/index.less b/src/grid-item/index.less
index a4879e96e..7cea0b221 100644
--- a/src/grid-item/index.less
+++ b/src/grid-item/index.less
@@ -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;
diff --git a/src/grid/test/__snapshots__/index.spec.js.snap b/src/grid/test/__snapshots__/index.spec.js.snap
index a66e337fb..e7d763ddc 100644
--- a/src/grid/test/__snapshots__/index.spec.js.snap
+++ b/src/grid/test/__snapshots__/index.spec.js.snap
@@ -9,6 +9,19 @@ exports[`icon-size prop 1`] = `
`;
+exports[`render icon-slot 1`] = `
+
+`;
+
exports[`sqaure and set gutter 1`] = `
diff --git a/src/grid/test/index.spec.js b/src/grid/test/index.spec.js
index e277c5e24..00375db15 100644
--- a/src/grid/test/index.spec.js
+++ b/src/grid/test/index.spec.js
@@ -50,3 +50,17 @@ test('icon-size prop', () => {
expect(wrapper).toMatchSnapshot();
});
+
+test('render icon-slot', () => {
+ const wrapper = mount({
+ template: `
+
+
+
+
+
+ `
+ });
+
+ expect(wrapper).toMatchSnapshot();
+});