Skip to content

Commit 517b583

Browse files
feat: ✨ Button按钮组件支持使用自定义组件
Closes: #310
1 parent 017aeda commit 517b583

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

docs/component/button.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
<wd-button icon="edit-outline"></wd-button>
8383
```
8484

85+
结合`classPrefix`可以使用自定义图标,参见 [Icon 自定义图标](/component/icon#自定义图标)
86+
```html
87+
<wd-button classPrefix="fish" icon="kehuishouwu">可回收</wd-button>
88+
```
89+
8590
## 块状按钮
8691

8792
设置 `block` 属性。
@@ -113,7 +118,7 @@
113118
| send-message-img | 会话内消息卡片图片,open-type="contact"时有效 | string | - | 截图 | - |
114119
| app-parameter | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | string | - | - | - |
115120
| show-message-card | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 | boolean | - | false | - |
116-
121+
| classPrefix | 类名前缀,用于使用自定义图标,参见[icon](/component/icon#自定义图标) | string | - | 'wd-icon' | 0.1.27 |
117122
## Events
118123

119124
| 事件名称 | 说明 | 参数 | 最低版本 |

docs/component/toast.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ toast.info('常规提示信息')
3232
```
3333

3434
## 使用图标
35-
可以使用`iconClass`指定图标,结合`classPrefix`可以使用自定义图标,参见[icon](/component/icon#自定义图标)
35+
可以使用`iconClass`指定图标,结合`classPrefix`可以使用自定义图标,参见 [Icon 自定义图标](/component/icon#自定义图标)
3636
```ts
3737
// 使用组件库内部图标
3838
toast.show({

src/pages/button/Index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<demo-block title="带图标的基本按钮">
6161
<wd-button icon="download">下载</wd-button>
6262
<wd-button icon="setting">设置</wd-button>
63+
<wd-button classPrefix="fish" icon="kehuishouwu">可回收</wd-button>
6364
<wd-button icon="download" size="small">下载</wd-button>
6465
<wd-button icon="setting" size="small">设置</wd-button>
6566
<wd-button icon="download" size="large">下载</wd-button>

src/uni_modules/wot-design-uni/components/wd-button/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* @Author: weisheng
33
* @Date: 2024-03-15 11:36:12
4-
* @LastEditTime: 2024-03-18 13:24:34
4+
* @LastEditTime: 2024-07-19 21:31:44
55
* @LastEditors: weisheng
66
* @Description:
7-
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\wd-button\types.ts
7+
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-button/types.ts
88
* 记得注释
99
*/
1010
import type { ExtractPropTypes } from 'vue'
@@ -47,6 +47,10 @@ export const buttonProps = {
4747
* 图标类名
4848
*/
4949
icon: String,
50+
/**
51+
* 类名前缀,用于使用自定义图标,用法参考Icon组件
52+
*/
53+
classPrefix: makeStringProp('wd-icon'),
5054
/**
5155
* 加载中按钮
5256
*/

src/uni_modules/wot-design-uni/components/wd-button/wd-button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<view v-if="loading" class="wd-button__loading">
4040
<view class="wd-button__loading-svg" :style="loadingStyle"></view>
4141
</view>
42-
<wd-icon v-else-if="icon" custom-class="wd-button__icon" :name="icon"></wd-icon>
42+
<wd-icon v-else-if="icon" custom-class="wd-button__icon" :name="icon" :classPrefix="classPrefix"></wd-icon>
4343
<view class="wd-button__text"><slot /></view>
4444
</button>
4545
</template>

0 commit comments

Comments
 (0)