Checkbox 勾选框
用于实现勾选,功能和 Switch 类似,只是展现上不同。
基本用法
```schema: scope=”body” { “type”: “form”, “body”: [ { “name”: “checkbox”, “type”: “checkbox”, “label”: “勾选框”, “option”: “选项说明” } ] }
## 配置真假值默认情况:- 勾选框勾选时,表单项值为:true- 勾选框取消勾选时,表单项值为:false```schema: scope="body"{"type": "form","debug": true,"body": [{"name": "checkbox","type": "checkbox","label": "勾选框","option": "选项说明"}]}
如果你想调整这个值,可以配置trueValue和falseValue
```schema: scope=”body” { “type”: “form”, “debug”: true, “body”: [ { “name”: “checkbox”, “type”: “checkbox”, “label”: “勾选框”, “option”: “选项说明”, “trueValue”: 1, “falseValue”: 0 } ] }
勾选上例中的勾选框,观察数据域变化,会发现勾选后值为`1`,而取消勾选后为`0`## 按钮模式```schema: scope="body"{"type": "form","debug": true,"body": [{"name": "checkbox","type": "checkbox","label": "勾选框","trueValue": true,"falseValue": false,"optionType": "button","option": "选项说明"}]}
属性表
除了支持 普通表单项属性表 中的配置以外,还支持下面一些配置
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| option | string |
选项说明 | |
| trueValue | string|number|boolean |
true |
标识真值 |
| falseValue | string|number|boolean |
false |
标识假值 |
| optionType | default|button |
default |
设置 option 类型 |
事件表
当前组件会对外派发以下事件,可以通过onEvent来监听这些事件,并通过actions来配置执行的动作,在actions中可以通过event.data.xxx事件参数变量来获取事件产生的数据,详细请查看事件动作。
| 事件名称 | 事件参数 | 说明 |
|---|---|---|
| change | event.data.value: boolean 选中状态 |
选中状态变化时触发 |
动作表
当前组件对外暴露以下特性动作,其他组件可以通过指定actionType: 动作名称、componentId: 该组件id来触发这些动作,动作配置可以通过args: {动作配置项名称: xxx}来配置具体的参数,详细请查看事件动作。
| 动作名称 | 动作配置 | 说明 | ||
|---|---|---|---|---|
| clear | - | 清空 | ||
| reset | - | 将值重置为resetValue,若没有配置resetValue,则清空 |
||
| setValue | `value: string \ | number \ | boolean` 更新的值 | 更新数据 |
