Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add_info_slot #5577

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
| size `v1.10.20` | 图标大小,如 `20px`,`2em`,默认单位为`px` | _string \| number_ | `inherit` |
| custom-style | 自定义样式 | _string_ | - |
| class-prefix | 类名前缀 | _string_ | `van-icon` |
| use-info-slot | 是否使用 info slot | _boolean_ | `false` |

### Events

Expand All @@ -103,6 +104,12 @@
| custom-class | 根节点样式类 |
| info-class | 图标右上角文字样式类 |

### Slot

| 类名 | 说明 |
| ------------ | ------------ |
| info-slot `v1.11.2` | 自定义info内容,开启useInfoSlot有效 |

## 常见问题

### 开发者工具上提示 Failed to load font 是什么情况?
Expand Down
1 change: 1 addition & 0 deletions packages/icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ VantComponent({
value: 'van-icon',
},
name: String,
useInfoSlot: Boolean,
},

methods: {
Expand Down
15 changes: 9 additions & 6 deletions packages/icon/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
style="{{ computed.rootStyle({ customStyle, color, size }) }}"
bindtap="onClick"
>
<van-info
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info info-class"
/>
<slot name="info-slot" wx:if="{{useInfoSlot}}"></slot>
<block wx:else>
<van-info
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info info-class"
/>
</block>
<image
wx:if="{{ computed.isImage(name) }}"
src="{{ name }}"
Expand Down
Loading