You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
856 B

10 years ago
# Switch
- category: Components
- chinese: 开关
- type: 表单
10 years ago
---
9 years ago
开关选择器。
10 years ago
## 何时使用
10 years ago
- 需要表示开关状态/两种状态之间的切换时;
-`checkbox `的区别是,切换 `switch` 会直接触发状态改变,而 `checkbox` 一般用于状态标记,需要和提交操作配合。
10 years ago
## API
### Switch
| 参数 | 说明 | 类型 | 可选值 |默认值 |
|-----------|------------------------------------------|------------|-------|--------|
| checked | 指定当前是否选中 | boolean | | false |
| defaultChecked | 初始是否选中 | boolean | | false |
10 years ago
| onChange | 变化时回调函数 | Function(checked:boolean) | | |
| checkedChildren | 选中时的内容 | React Node | | |
9 years ago
| unCheckedChildren | 非选中时的内容 | React Node | | |