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