Appearance
if/else 
if/else控件用于进行条件判断,目前仅支持if、else两部分,不支持else if。
默认仅使用if,如需使用else,可点击IF控件右上角的折叠按钮对控件进行展开。
业务属性 
| 属性 | 含义 | 说明 | 输入限定 | 示例值 | 
|---|---|---|---|---|
| enable | 是否启用该控件,未启用时不编译 | 是否编译 | 选择值 | 启用 | 
| text | 与控件关联的文本 | 设计页控件显示 | 常量 | ifElse | 
| expression | 判断表达式 | Lua判断表达式 | Lua脚本 | var1==var2 | 
判断表达式完全遵循Lua语言的语法,其中不等于、逻辑与、逻辑或和逻辑非分别用~=、and、or和not表示,在判断表达式中变量的表示无需使用#{}占位符,直接书写变量名即可。
使用示例 
if 
判断表达式输入:body.param ~= true

添加输出控件,输出字符串this is if

使用curl请求接口:
$ curl http://localhost:6636/api/if -d "{ \"param\": false }"$ curl http://localhost:6636/api/if -d "{ \"param\": false }"此时param属性为false
接口返回:
json
{
  "resCode": "0",
  "resMsg": "success",
  "data": "this is if"
}{
  "resCode": "0",
  "resMsg": "success",
  "data": "this is if"
}if else 
点击右上角折叠按钮,展开else控件,添加输出控件,输出字符串this is else

使用curl请求接口:
$ curl http://localhost:6636/api/if -d "{ \"param\": true }"$ curl http://localhost:6636/api/if -d "{ \"param\": true }"此时param属性为true
接口返回:
json
{
  "resCode": "0",
  "resMsg": "success",
  "data": "this is else"
}{
  "resCode": "0",
  "resMsg": "success",
  "data": "this is else"
}