mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-15 17:31:18 +08:00
0ae04ce946
* docs:将文档移动 zh-CN 目录下;为以后支持英文版做准备 * 整理 autoFill * 补充下载最新版本的说明 (#1298) * fix: 修复在新版 Firefox 下 js sdk 报错 (#1300) * 删掉可能报错的代码 (#1311) * fix: 修复 css 变量不支持数字问题 (#1302) * feat:增加 animation-duration,可以控制所有动画时长,也能用于一次性关闭所有动画效果 (#1303) * feat:增加 animation-duration,可以控制所有动画时长,也能用于一次性关闭所有动画效果 * 补充文档 * Pageleave (#1310) * form 添加页面离开提示功能 * 补充文档 Co-authored-by: 2betop <2betop.cn@gmail.com> Co-authored-by: liaoxuezhi <liaoxuezhi@baidu.com>
82 lines
1.6 KiB
Markdown
Executable File
82 lines
1.6 KiB
Markdown
Executable File
---
|
||
title: Switch 开关
|
||
description:
|
||
type: 0
|
||
group: null
|
||
menuName: Switch
|
||
icon:
|
||
order: 51
|
||
---
|
||
## 基本用法
|
||
|
||
```schema:height="300" scope="body"
|
||
{
|
||
"type": "form",
|
||
"api": "https://houtai.baidu.com/api/mock2/form/saveForm",
|
||
"controls": [
|
||
{
|
||
"name": "switch",
|
||
"type": "switch",
|
||
"label": "开关",
|
||
"option": "开关说明"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
|
||
## 配置真假值
|
||
|
||
默认情况:
|
||
- 开关打开时,表单项值为:true
|
||
- 开关关闭时,表单项值为:false
|
||
|
||
```schema:height="350" scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"controls": [
|
||
{
|
||
"name": "switch",
|
||
"type": "switch",
|
||
"label": "开关"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
如果你想调整这个值,可以配置`trueValue`和`falseValue`
|
||
|
||
```schema:height="350" scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"controls": [
|
||
{
|
||
"name": "switch",
|
||
"type": "switch",
|
||
"label": "开关",
|
||
"trueValue": 1,
|
||
"falseValue": 0
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
调整开关,观察数据域变化,会发现打开后值为`1`,而关闭后为`0`
|
||
|
||
## 属性表
|
||
|
||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||
|
||
| 属性名 | 类型 | 默认值 | 说明 |
|
||
| ---------- | -------- | --------- | -------- |
|
||
| option | `string` | | 选项说明 |
|
||
| trueValue | `any` | `true` | 标识真值 |
|
||
| falseValue | `any` | `"false"` | 标识假值 |
|
||
|
||
|
||
|
||
|
||
|