ant-design/components/button/index.zh-CN.md

54 lines
2.2 KiB
Markdown
Raw Normal View History

2016-03-31 14:17:09 +08:00
---
category: Components
type: 通用
title: Button
subtitle: 按钮
2016-03-31 14:17:09 +08:00
---
2015-05-12 17:50:03 +08:00
2015-06-17 18:22:20 +08:00
按钮用于开始一个即时操作。
2015-06-14 17:54:08 +08:00
2015-05-27 15:43:29 +08:00
## 何时使用
2015-05-15 18:03:27 +08:00
2015-06-17 17:43:04 +08:00
标记了一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。
2015-06-14 17:54:08 +08:00
2015-10-29 23:17:25 +08:00
## API
2019-02-17 23:07:02 +08:00
通过设置 Button 的属性来产生不同的按钮样式,推荐顺序为:`type` -> `shape` -> `size` -> `loading` -> `disabled`
2015-09-27 16:30:35 +08:00
2016-03-25 18:13:51 +08:00
按钮的属性说明如下:
2015-09-27 16:30:35 +08:00
2017-10-25 10:25:44 +08:00
| 属性 | 说明 | 类型 | 默认值 |
2019-05-07 14:57:32 +08:00
| --- | --- | --- | --- |
2018-06-24 17:09:18 +08:00
| disabled | 按钮失效状态 | boolean | `false` |
2017-10-25 10:25:44 +08:00
| ghost | 幽灵属性,使按钮背景透明,版本 2.7 中增加 | boolean | false |
2017-12-29 20:22:58 +08:00
| href | 点击跳转的地址,指定此属性 button 的行为和 a 链接一致 | string | - |
2017-10-25 10:25:44 +08:00
| htmlType | 设置 `button` 原生的 `type` 值,可选值请参考 [HTML 标准](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type) | string | `button` |
| icon | 设置按钮的图标类型 | string | - |
| loading | 设置按钮载入状态 | boolean \| { delay: number } | `false` |
| shape | 设置按钮形状,可选值为 `circle``round` 或者不设 | string | - |
2017-10-25 10:25:44 +08:00
| size | 设置按钮大小,可选值为 `small` `large` 或者不设 | string | `default` |
2017-12-29 20:22:58 +08:00
| target | 相当于 a 链接的 target 属性href 存在时生效 | string | - |
meger feature to master (#16421) * use ul in list * update snapshot * update comment * feat: TreeSelect support `showSearch` in multiple mode (#15933) * update rc-tree-select * typo * update desc & snapshot * update desc & snapshot * check default showSearch * feat: table customizing variable (#15971) * feat: added table selected row color variable * fix: @table-selected-row-color default is inherit * feat: Upload support customize previewFile (#15984) * support preview file * use promise * dealy load * use canvas of render * use domHook of test * update demo * add snapshot * update types * update testcase * feat: form customizing variables (#15954) * fix: added styling form input background-color * feat: added '@form-warning-input-bg' variable * feat: added '@form-error-input-bg' variable * use li wrap with comment * feat: Support append theme less file with less-variable (#16118) * add override * add override support * update doc * feat: dropdown support set right icon * docs: update doc of dropdown component * style: format dropdown-button.md * test: update updateSnapshot * style: format dropdown-button.md * test: update updateSnapshot * test: update updateSnapshot * style: change style of dropdown-button demo * fix: fix document table order * feat: Support SkeletonAvatarProps.size accept number (#16078) (#16128) * chore:update style of demo * feat: Notification functions accept top, bottom and getContainer as arguments * drawer: add afterVisibleChange * rm onVisibleChange * update * feat: 🇭🇷 hr_HR locale (#16258) * Added Croatian locale * fixed lint error * :white_check_mark: Add test cases for hr_HR * :memo: update i18n documentation * feat: add `htmlFor` in Form.Item (#16278) * add htmlFor in Form.Item * update doc * feat: Button support `link` type (#16289) close #15892 * feat: Add Timeline.Item.position (#16148) (#16193) * fix: Timeline.pendingDot interface documentation there is a small problem (#16177) * feat: Add Timeline.Item.position (#16148) * doc: add version infomation for Timeline.Item.position * refactor: Update Tree & TreeSelect deps (#16330) * use CSSMotion * update snapshot * feat: Collapse support `expandIconPosition` (#16365) * update doc * support expandIconPosition * update snapshot * feat: Breadcrumb support DropDown (#16315) * breadcrumbs support drop down menu * update doc * add require less * fix test * fix md doc * less code * fix style warning * update snap * add children render test * feat: TreeNode support checkable * feat: add optional to support top and left slick dots (#16186) (#16225) * add optional to support top and left slick dots * update carousel snapshot * Update doc, add placement demo * update carousel placement demo snapshots * rename dots placement to position * update vertical as deprecated * rename dotsPosition to dotPosition * refine code * add warning testcase for vertical * remove unused warning * update expression * Additional test case for dotPosition * refactor: Upgrade `rc-tree-select` to support pure React motion (#16402) * upgrade `rc-tree-select` * update snapshot * 3.17.0 changelog * fix warning * fix review warning
2019-05-06 12:04:39 +08:00
| type | 设置按钮类型,可选值为 `primary` `dashed` `danger` `link`(3.17 中增加) 或者不设 | string | - |
2018-10-28 20:57:23 +08:00
| onClick | 点击按钮时的回调 | (event) => void | - |
| block | 将按钮宽度调整为其父宽度的选项 | boolean | `false` |
2015-09-27 16:30:35 +08:00
2018-10-28 20:57:23 +08:00
支持原生 button 的其他所有属性。
## FAQ
### 如何移除两个汉字之间的空格?
根据 Ant Design 设计规范要求,我们会在按钮内只有两个汉字时自动添加空格,如果你不需要这个特性,可以设置 [ConfigProvider](/components/config-provider/#API) 的 `autoInsertSpaceInButton``false`
![](https://gw.alipayobjects.com/zos/antfincdn/Hz5HL9gsT4/f29f170d-b78d-4d2b-aa71-0da6a9ead4d9.png)
<style>
[id^="components-button-demo-"] .ant-btn {
margin-right: 8px;
margin-bottom: 12px;
}
[id^="components-button-demo-"] .ant-btn-group > .ant-btn {
margin-right: 0;
}
</style>