diff --git a/components/button/button.jsx b/components/button/button.jsx index e92b66cda..b113d3b7e 100644 --- a/components/button/button.jsx +++ b/components/button/button.jsx @@ -1,7 +1,7 @@ import Wave from '../_util/wave'; import Icon from '../icon'; import buttonTypes from './buttonTypes'; -import { filterEmpty, getListeners } from '../_util/props-util'; +import { filterEmpty, getListeners, getComponentFromProp } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/; @@ -134,12 +134,14 @@ export default { return child; }, isNeedInserted() { - const { icon, $slots, type } = this; + const { $slots, type } = this; + const icon = getComponentFromProp(this, 'icon'); return $slots.default && $slots.default.length === 1 && !icon && type !== 'link'; }, }, render() { - const { type, htmlType, classes, icon, disabled, handleClick, sLoading, $slots, $attrs } = this; + const { type, htmlType, classes, disabled, handleClick, sLoading, $slots, $attrs } = this; + const icon = getComponentFromProp(this, 'icon'); const buttonProps = { attrs: { ...$attrs, diff --git a/components/button/buttonTypes.js b/components/button/buttonTypes.js index 14fa70f37..978d85322 100644 --- a/components/button/buttonTypes.js +++ b/components/button/buttonTypes.js @@ -3,7 +3,7 @@ export default () => ({ prefixCls: PropTypes.string, type: PropTypes.string, htmlType: PropTypes.oneOf(['button', 'submit', 'reset']).def('button'), - icon: PropTypes.string, + icon: PropTypes.any, shape: PropTypes.oneOf(['circle', 'circle-outline', 'round']), size: PropTypes.oneOf(['small', 'large', 'default']).def('default'), loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),