mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
d44f404eae
* chore: improve sort api table scripts * sort api * add ignore * Revert "sort api" This reverts commit 343505d5f09d69349ce1fbdaea2a9faa7e852207. * sort api * Update package.json * sort api * Delete sort-api.js * sort api * sort api * sort api * fix * Update index.zh-CN.md * fix input-number * fix input-number * sort func * fix * Method moved to the end * carousel method
38 lines
1.2 KiB
Markdown
38 lines
1.2 KiB
Markdown
---
|
|
category: Components
|
|
subtitle: 开关
|
|
type: 数据录入
|
|
title: Switch
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/zNdJQMhfm/Switch.svg
|
|
---
|
|
|
|
开关选择器。
|
|
|
|
## 何时使用
|
|
|
|
- 需要表示开关状态/两种状态之间的切换时;
|
|
- 和 `checkbox`的区别是,切换 `switch` 会直接触发状态改变,而 `checkbox` 一般用于状态标记,需要和提交操作配合。
|
|
|
|
## API
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
| --- | --- | --- | --- |
|
|
| autoFocus | 组件自动获取焦点 | boolean | false |
|
|
| checked | 指定当前是否选中 | boolean | false |
|
|
| checkedChildren | 选中时的内容 | ReactNode | - |
|
|
| className | Switch 器类名 | string | - |
|
|
| defaultChecked | 初始是否选中 | boolean | false |
|
|
| disabled | 是否禁用 | boolean | false |
|
|
| loading | 加载中的开关 | boolean | false |
|
|
| size | 开关大小,可选值:`default` `small` | string | `default` |
|
|
| unCheckedChildren | 非选中时的内容 | ReactNode | - |
|
|
| onChange | 变化时回调函数 | function(checked: boolean, event: Event) | - |
|
|
| onClick | 点击时回调函数 | function(checked: boolean, event: Event) | - |
|
|
|
|
## 方法
|
|
|
|
| 名称 | 描述 |
|
|
| --- | --- |
|
|
| blur() | 移除焦点 |
|
|
| focus() | 获取焦点 |
|