mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
882cec62d6
* docs: Add components overview page * fix detail * remove ContributorsList form overview page * fix components url * improve code style * remove extra file * fix detail * fix lint * fix lint * docs: Finish components overview page * fix lint * docs: Update cover * fix lint * update cover * update menu * improve overview page * refactor code * fix order * update title * add components count * fix overview page ssr bug * move less file * update title margin Co-authored-by: arvinxx <arvinx@foxmail.com>
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 | 选中时的内容 | string\|ReactNode | |
|
|
| defaultChecked | 初始是否选中 | boolean | false |
|
|
| disabled | 是否禁用 | boolean | false |
|
|
| loading | 加载中的开关 | boolean | false |
|
|
| size | 开关大小,可选值:`default` `small` | string | default |
|
|
| unCheckedChildren | 非选中时的内容 | string\|ReactNode | |
|
|
| onChange | 变化时回调函数 | Function(checked: boolean, event: Event) | |
|
|
| onClick | 点击时回调函数 | Function(checked: boolean, event: Event) | |
|
|
| className | Switch 器类名 | string | |
|
|
|
|
## 方法
|
|
|
|
| 名称 | 描述 |
|
|
| ------- | -------- |
|
|
| blur() | 移除焦点 |
|
|
| focus() | 获取焦点 |
|