mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-07 09:09:30 +08:00
@@ -7,6 +7,7 @@ exports[`Button should render empty button correctly 1`] = `
|
||||
disabled={false}
|
||||
effect={true}
|
||||
ghost={false}
|
||||
htmlType="button"
|
||||
loading={false}
|
||||
shadow={false}
|
||||
size="medium"
|
||||
@@ -23,6 +24,7 @@ exports[`Button should render special styles 2`] = `
|
||||
disabled={false}
|
||||
effect={true}
|
||||
ghost={false}
|
||||
htmlType="button"
|
||||
loading={true}
|
||||
shadow={false}
|
||||
size="medium"
|
||||
|
||||
@@ -17,6 +17,7 @@ interface Props {
|
||||
auto?: boolean
|
||||
effect?: boolean
|
||||
disabled?: boolean
|
||||
htmlType?: React.ButtonHTMLAttributes<any>['type']
|
||||
icon?: React.ReactNode
|
||||
iconRight?: React.ReactNode
|
||||
onClick?: React.MouseEventHandler<HTMLButtonElement>
|
||||
@@ -26,6 +27,7 @@ interface Props {
|
||||
const defaultProps = {
|
||||
type: 'default' as ButtonTypes,
|
||||
size: 'medium' as NormalSizes,
|
||||
htmlType: 'button' as React.ButtonHTMLAttributes<any>['type'],
|
||||
ghost: false,
|
||||
loading: false,
|
||||
shadow: false,
|
||||
@@ -57,6 +59,7 @@ const Button: React.FC<React.PropsWithChildren<ButtonProps>> = ({ ...btnProps })
|
||||
auto,
|
||||
size,
|
||||
icon,
|
||||
htmlType,
|
||||
iconRight,
|
||||
className,
|
||||
...props
|
||||
@@ -115,7 +118,7 @@ const Button: React.FC<React.PropsWithChildren<ButtonProps>> = ({ ...btnProps })
|
||||
return (
|
||||
<button
|
||||
ref={buttonRef}
|
||||
type="button"
|
||||
type={htmlType}
|
||||
className={`btn ${className}`}
|
||||
disabled={disabled}
|
||||
onClick={clickHandler}
|
||||
|
||||
@@ -123,6 +123,7 @@ Used to trigger an operation.
|
||||
| **effect** | display animation | `boolean` | - | `true` |
|
||||
| **disabled** | disable button | `boolean` | - | `false` |
|
||||
| **icon** | show icon in button | `ReactNode` | - | - |
|
||||
| **htmlType** | native type of button element | `ButtonHTMLAttributes.type` | - | `button` |
|
||||
| **iconRight** | show icon on the other side of the button | `ReactNode` | - | - |
|
||||
| **onClick** | click handler | `MouseEventHandler` | - | - |
|
||||
| ... | native props | `ButtonHTMLAttributes` | `'id', 'className', ...` | - |
|
||||
|
||||
@@ -124,6 +124,7 @@ export const meta = {
|
||||
| **onClick** | 点击事件 | `MouseEventHandler` | - | - |
|
||||
| **icon** | 在按钮内显示图标 | `ReactNode` | - | - |
|
||||
| **iconRight** | 在按钮的另一侧显示图标 | `ReactNode` | - | - |
|
||||
| **htmlType** | 按钮的原生类型属性 | `ButtonHTMLAttributes.type` | - | `button` |
|
||||
| ... | 原生属性 | `ButtonHTMLAttributes` | `'id', 'className', ...` | - |
|
||||
|
||||
<Attributes.Title>ButtonTypes</Attributes.Title>
|
||||
|
||||
Reference in New Issue
Block a user