mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(Button): add icon slot (#8784)
This commit is contained in:
parent
55cb436188
commit
e97f5cea71
@ -139,6 +139,7 @@ Vue.use(Button);
|
|||||||
| Name | Description |
|
| Name | Description |
|
||||||
| ----------------- | ------------------- |
|
| ----------------- | ------------------- |
|
||||||
| default | Default slot |
|
| default | Default slot |
|
||||||
|
| icon `v2.12.21` | Custom icon |
|
||||||
| loading `v2.10.1` | Custom loading icon |
|
| loading `v2.10.1` | Custom loading icon |
|
||||||
|
|
||||||
### Less Variables
|
### Less Variables
|
||||||
|
@ -166,6 +166,7 @@ Vue.use(Button);
|
|||||||
| 名称 | 说明 |
|
| 名称 | 说明 |
|
||||||
| ----------------- | -------------- |
|
| ----------------- | -------------- |
|
||||||
| default | 按钮内容 |
|
| default | 按钮内容 |
|
||||||
|
| icon `v2.12.21` | 自定义图标 |
|
||||||
| loading `v2.10.1` | 自定义加载图标 |
|
| loading `v2.10.1` | 自定义加载图标 |
|
||||||
|
|
||||||
### 样式变量
|
### 样式变量
|
||||||
|
@ -43,6 +43,7 @@ export type ButtonEvents = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ButtonSlots = DefaultSlots & {
|
export type ButtonSlots = DefaultSlots & {
|
||||||
|
icon?: ScopedSlot;
|
||||||
loading?: ScopedSlot;
|
loading?: ScopedSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -130,6 +131,10 @@ function Button(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slots.icon) {
|
||||||
|
return <div class={bem('icon')}>{slots.icon()}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
return (
|
return (
|
||||||
<Icon name={icon} class={bem('icon')} classPrefix={props.iconPrefix} />
|
<Icon name={icon} class={bem('icon')} classPrefix={props.iconPrefix} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user