Skip to content

Commit 5abc3b5

Browse files
fix: 🐛 修复 grid-item 组件 custom-text 失效的问题 (#1180)
✅ Closes: #995
1 parent 73ac641 commit 5abc3b5

6 files changed

Lines changed: 39 additions & 36 deletions

File tree

‎docs/.vitepress/config/version-data.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
export const versionData = {
66
"/component/count-to": "1.3.8",
77
"/component/keyboard": "1.3.10",
8-
"/component/root-portal": "$LOWEST_VERSION$",
8+
"/component/root-portal": "1.11.0",
99
"/component/signature": "1.6.0"
1010
}

‎docs/component/grid.md‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,15 @@
6363

6464
通过默认插槽可以自定义 `GridItem` 的内容。
6565

66-
使用默认插槽过程中, 开启 `GridItem` 上的属性 `use-slot`。
67-
6866
```html
6967
<wd-grid>
70-
<wd-grid-item use-slot>
68+
<wd-grid-item>
7169
<image class="img" :src="joy" />
7270
</wd-grid-item>
73-
<wd-grid-item use-slot>
71+
<wd-grid-item>
7472
<image class="img" :src="joy" />
7573
</wd-grid-item>
76-
<wd-grid-item use-slot>
74+
<wd-grid-item>
7775
<image class="img" :src="joy" />
7876
</wd-grid-item>
7977
</wd-grid>
@@ -88,9 +86,9 @@
8886

8987
## 单个插槽
9088

91-
通过插槽 `icon` 可以插入 `GridItem` 中的图标位。通过 `use-icon-slot` 开启图标插槽。
89+
通过插槽 `icon` 可以插入 `GridItem` 中的图标位。
9290

93-
通过插槽 `text` 可以插入 `GridItem` 中的文字位。通过 `use-text-slot` 开启文字插槽。
91+
通过插槽 `text` 可以插入 `GridItem` 中的文字位。
9492

9593
注意:
9694

@@ -100,14 +98,14 @@
10098

10199
```html
102100
<wd-grid>
103-
<wd-grid-item use-icon-slot text="文字" v-for="index in 3" :key="index" icon-size="36px">
101+
<wd-grid-item text="文字" v-for="index in 3" :key="index" icon-size="36px">
104102
<template #icon>
105103
<image class="slot-img" :src="joy" />
106104
</template>
107105
</wd-grid-item>
108106
</wd-grid>
109107
<wd-grid>
110-
<wd-grid-item use-text-slot icon="picture" v-for="index in 3" :key="index">
108+
<wd-grid-item icon="picture" v-for="index in 3" :key="index">
111109
<template #text>
112110
<view class="text">自定义文字插槽</view>
113111
</template>
@@ -243,9 +241,9 @@
243241
| max | 图标右上角 `badge` 最大值,超过最大值会显示 '{max}+',要求 value 是 Number 类型 | number | - | - | - |
244242
| url | 点击后跳转的链接地址 | string | - | - | - |
245243
| link-type | 页面跳转方式, 参考[微信小程序路由文档](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/route.html) | string | navigateTo / switchTab / reLaunch | - | - |
246-
| use-slot | 是否开启 `GridItem` 内容插槽 | boolean | - | false | - |
247-
| use-icon-slot | 是否开启 `GridItem` icon 插槽 | boolean | - | false | - |
248-
| use-text-slot | 是否开启 `GridItem` text 内容插槽 | boolean | - | false | - |
244+
| <s>use-slot</s> | 是否开启 `GridItem` 内容插槽 **($LOWEST_VERSION$已废弃,直接使用默认插槽即可)** | boolean | - | false | - |
245+
| <s>use-icon-slot</s> | 是否开启 `GridItem` icon 插槽 **($LOWEST_VERSION$已废弃,组件会自动检测icon插槽的存在)** | boolean | - | false | - |
246+
| <s>use-text-slot</s> | 是否开启 `GridItem` text 内容插槽 **($LOWEST_VERSION$已废弃,组件会自动检测text插槽的存在)** | boolean | - | false | - |
249247
| icon-size | 图标大小 | string | - | 26px | - |
250248
| badge-props | 自定义徽标的属性,传入的对象会被透传给 [Badge 组件的 props](/component/badge#attributes) | BadgeProps | - | - | 0.1.50 |
251249

‎docs/en-US/component/grid.md‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,15 @@ Basic usage requires binding the `icon` value and `text` property. By default, i
6363

6464
The content of `GridItem` can be customized through the default slot.
6565

66-
When using the default slot, enable the `use-slot` property on `GridItem`.
67-
6866
```html
6967
<wd-grid>
70-
<wd-grid-item use-slot>
68+
<wd-grid-item>
7169
<image class="img" :src="joy" />
7270
</wd-grid-item>
73-
<wd-grid-item use-slot>
71+
<wd-grid-item>
7472
<image class="img" :src="joy" />
7573
</wd-grid-item>
76-
<wd-grid-item use-slot>
74+
<wd-grid-item>
7775
<image class="img" :src="joy" />
7876
</wd-grid-item>
7977
</wd-grid>
@@ -88,9 +86,9 @@ When using the default slot, enable the `use-slot` property on `GridItem`.
8886

8987
## Individual Slots
9088

91-
The `icon` slot can be inserted into the icon position of `GridItem`. Enable the icon slot through `use-icon-slot`.
89+
The `icon` slot can be inserted into the icon position of `GridItem`.
9290

93-
The `text` slot can be inserted into the text position of `GridItem`. Enable the text slot through `use-text-slot`.
91+
The `text` slot can be inserted into the text position of `GridItem`.
9492

9593
Note:
9694

@@ -100,14 +98,14 @@ Note:
10098

10199
```html
102100
<wd-grid>
103-
<wd-grid-item use-icon-slot text="Text" v-for="index in 3" :key="index" icon-size="36px">
101+
<wd-grid-item text="Text" v-for="index in 3" :key="index" icon-size="36px">
104102
<template #icon>
105103
<image class="slot-img" :src="joy" />
106104
</template>
107105
</wd-grid-item>
108106
</wd-grid>
109107
<wd-grid>
110-
<wd-grid-item use-text-slot icon="picture" v-for="index in 3" :key="index">
108+
<wd-grid-item icon="picture" v-for="index in 3" :key="index">
111109
<template #text>
112110
<view class="text">Custom Text Slot</view>
113111
</template>
@@ -230,9 +228,9 @@ Set jump link through `url` property.
230228
| icon-size | Icon size | string | '26px' | - |
231229
| url | Page jump link | string | - | - |
232230
| link-type | Page jump type | string | 'navigateTo' | - |
233-
| use-slot | Whether to use slot | boolean | false | - |
234-
| use-icon-slot | Whether to use icon slot | boolean | false | - |
235-
| use-text-slot | Whether to use text slot | boolean | false | - |
231+
| <s>use-slot</s> | Whether to use slot **($LOWEST_VERSION$Deprecated, use default slot directly)** | boolean | false | - |
232+
| <s>use-icon-slot</s> | Whether to use icon slot **($LOWEST_VERSION$Deprecated, component auto-detects icon slot existence)** | boolean | false | - |
233+
| <s>use-text-slot</s> | Whether to use text slot **($LOWEST_VERSION$Deprecated, component auto-detects text slot existence)** | boolean | false | - |
236234
| clickable | Whether clickable | boolean | false | - |
237235

238236
## GridItem Events

‎src/uni_modules/wot-design-uni/components/wd-grid-item/types.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ export const gridItemProps = {
3636
linkType: makeStringProp<LinkType>('navigateTo'),
3737
/**
3838
* 是否开启 GridItem 内容插槽
39+
* @deprecated 已废弃,直接使用默认插槽即可
3940
*/
4041
useSlot: makeBooleanProp(false),
4142
/**
4243
* 是否开启 GridItem icon 插槽
44+
* @deprecated 已废弃,组件会自动根据 icon 插槽是否存在来显示
4345
*/
4446
useIconSlot: makeBooleanProp(false),
4547
/**
4648
* 是否开启 GridItem text 内容插槽
49+
* @deprecated 已废弃,组件会自动根据 text 插槽是否存在来显示
4750
*/
4851
useTextSlot: makeBooleanProp(false),
4952
/**

‎src/uni_modules/wot-design-uni/components/wd-grid-item/wd-grid-item.vue‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
:style="gutterContentStyle"
66
:hover-class="hoverClass"
77
>
8-
<slot v-if="useSlot" />
9-
<block v-else>
10-
<view :style="'width:' + iconSize + '; height: ' + iconSize" class="wd-grid-item__wrapper">
11-
<wd-badge custom-class="badge" v-bind="customBadgeProps">
12-
<template v-if="useIconSlot">
13-
<slot name="icon" />
14-
</template>
15-
<wd-icon v-else :name="icon" :size="iconSize" :custom-class="customIcon" />
8+
<slot>
9+
<view class="wd-grid-item__wrapper">
10+
<wd-badge v-bind="customBadgeProps">
11+
<slot name="icon">
12+
<wd-icon :name="icon" :size="iconSize" :custom-class="customIcon" />
13+
</slot>
1614
</wd-badge>
1715
</view>
18-
<slot name="text" v-if="useTextSlot" />
19-
<view v-else class="wd-grid-item__text custom-text">{{ text }}</view>
20-
</block>
16+
<slot name="text">
17+
<view :class="`wd-grid-item__text ${customText}`">{{ text }}</view>
18+
</slot>
19+
</slot>
2120
</view>
2221
</view>
2322
</template>

‎src/uni_modules/wot-design-uni/components/wd-icon/index.scss‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@
2828
font-weight: normal;
2929
font-variant: normal;
3030
text-transform: none;
31+
line-height: 1;
3132
/* Better Font Rendering =========== */
3233
-webkit-font-smoothing: antialiased;
3334
-moz-osx-font-smoothing: grayscale;
3435

36+
&::before {
37+
display: inline-block;
38+
}
39+
3540
@include m(image) {
3641
width: 1em;
3742
height: 1em;

0 commit comments

Comments
 (0)