mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
feat: add support for htmlType
This commit is contained in:
parent
f4ca0798de
commit
1e45e02e8a
@ -26,7 +26,7 @@ function insertSpace(child) {
|
||||
export default class Button extends React.Component {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const {type, shape, size, onClick, className, children, ...others} = props;
|
||||
const {type, shape, size, onClick, className, htmlType, children, ...others} = props;
|
||||
|
||||
const classes = rcUtil.classSet({
|
||||
'ant-btn': true,
|
||||
@ -39,7 +39,7 @@ export default class Button extends React.Component {
|
||||
|
||||
const kids = React.Children.map(children, insertSpace);
|
||||
|
||||
return <button {...others} type="button" className={classes} onClick={onClick}>
|
||||
return <button {...others} type={htmlType || 'button'} className={classes} onClick={onClick}>
|
||||
{kids}
|
||||
</button>;
|
||||
}
|
||||
|
@ -22,9 +22,10 @@
|
||||
属性 | 说明 | 类型 | 默认值
|
||||
-----|-----|-----|------
|
||||
type | 设置按钮类型,可选值为 `primary` `ghost` 或者不设 | Enum | undefined
|
||||
htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 HTML标准 | Enum | `button`
|
||||
shape | 设置按钮形状,可选值为 `circle` `circle-outline` 或者不设 | Enum | undefined
|
||||
size | 设置按钮大小,可选值为 `sm` `lg` 或者不设 | Enum | undefined
|
||||
loading | 设置按钮载入状态,存在为 `true`,不存在为 `false`,或直接设置值,如:`loading="true"` | Bool | false
|
||||
onClick | `click` 事件的 handler | Function | `function() {}`
|
||||
|
||||
- `<Button>Hello world!</Button>` 最终会被渲染为 `<button type="button">Hello world!</button>`,并且除了上表中的属性,其它属性都会直接传到 `<button></button>`
|
||||
- `<Button>Hello world!</Button>` 最终会被渲染为 `<button>Hello world!</button>`,并且除了上表中的属性,其它属性都会直接传到 `<button></button>`
|
||||
|
Loading…
Reference in New Issue
Block a user