From e97f5cea71ec6a840d5db5ed2f7e24647e23cc81 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 30 May 2021 20:56:48 +0800 Subject: [PATCH] feat(Button): add icon slot (#8784) --- src/button/README.md | 1 + src/button/README.zh-CN.md | 1 + src/button/index.tsx | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/src/button/README.md b/src/button/README.md index 60b52beef..ace847b72 100644 --- a/src/button/README.md +++ b/src/button/README.md @@ -139,6 +139,7 @@ Vue.use(Button); | Name | Description | | ----------------- | ------------------- | | default | Default slot | +| icon `v2.12.21` | Custom icon | | loading `v2.10.1` | Custom loading icon | ### Less Variables diff --git a/src/button/README.zh-CN.md b/src/button/README.zh-CN.md index daf9831d2..b6f57039f 100644 --- a/src/button/README.zh-CN.md +++ b/src/button/README.zh-CN.md @@ -166,6 +166,7 @@ Vue.use(Button); | 名称 | 说明 | | ----------------- | -------------- | | default | 按钮内容 | +| icon `v2.12.21` | 自定义图标 | | loading `v2.10.1` | 自定义加载图标 | ### 样式变量 diff --git a/src/button/index.tsx b/src/button/index.tsx index fc1c8f8e5..6dff5cc7b 100644 --- a/src/button/index.tsx +++ b/src/button/index.tsx @@ -43,6 +43,7 @@ export type ButtonEvents = { }; export type ButtonSlots = DefaultSlots & { + icon?: ScopedSlot; loading?: ScopedSlot; }; @@ -130,6 +131,10 @@ function Button( ); } + if (slots.icon) { + return
{slots.icon()}
; + } + if (icon) { return (