Skip to content

Commit 89da488

Browse files
authored
feat(Fab): add default slot (#3204)
1 parent becc87a commit 89da488

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/button/button.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { SuperComponent, wxComponent } from '../common/src/index';
22
import config from '../common/config';
33
import props from './props';
44
import { canIUseFormFieldButton } from '../common/version';
5-
import { setIcon } from '../common/utils';
5+
import { calcIcon } from '../common/utils';
66
import type { TdButtonProps } from './type';
77

88
const { prefix } = config;
@@ -33,9 +33,8 @@ export default class Button extends SuperComponent {
3333
},
3434

3535
icon(icon) {
36-
const obj = setIcon('icon', icon, '');
3736
this.setData({
38-
...obj,
37+
_icon: calcIcon(icon, ''),
3938
});
4039
},
4140
};

src/button/button.wxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
aria-label="{{ariaLabel}}"
3232
>
3333
<template
34-
wx:if="{{iconName || _.isNoEmptyObj(iconData)}}"
34+
wx:if="{{_icon}}"
3535
is="icon"
36-
data="{{class: classPrefix + '__icon', tClass: prefix + '-class-icon', ariaHidden: true, name: iconName, ...iconData}}"
36+
data="{{class: classPrefix + '__icon', tClass: prefix + '-class-icon', ariaHidden: true, name: iconName, ..._icon}}"
3737
/>
3838
<t-loading
3939
wx:if="{{loading}}"

src/common/template/button.wxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@
3636
bind:launchapp="onTplButtonTap"
3737
bind:agreeprivacyauthorization="onTplButtonTap"
3838
aria-label="{{ariaLabel || ''}}"
39-
/>
39+
>
40+
<slot />
41+
</t-button>
4042
</template>

0 commit comments

Comments
 (0)