showInPanel控制组件的展示规则。

配置项说明

参数 子参数 备注
conditions 配置条件,array类型。其中的每一项用长度为3的数组描述一个判断条件,数组中包含pathoperatorvalue

path 配置条件依赖的配置项的路径,支持绝对路径和相对路径:
- 绝对路径:从顶层根节点开始,使用.来拼接路径,例如global.color
- 相对路径:从当前配置开始,用.来定位路径,例如.text ..label.show

operator 操作符,支持的类型包括:
- $eq:相等
- $ne:不相等
- $gt:大于
- $lt:小于
- $gte:大于等于
- $lte:小于等于
- $in:在数组中
- $nin:不在数组中
value 配置项的值
logicalType conditions定义了若干条件,logicalType则定义了条件之间的逻辑关系。可选值包括$and(与)和$or(或),默认为$and

示例
image.pngimage.png

配置示例

  1. "switch": {
  2. "type": "switch",
  3. "name": "单开关",
  4. "default": false
  5. },
  6. "showInPanel": {
  7. "type": "text",
  8. "name": "显示",
  9. "default": "开关控制",
  10. "showInPanel": [
  11. [
  12. ".switch",
  13. "$eq",
  14. true
  15. ]
  16. ]
  17. },
  18. "switchAnd1": {
  19. "type": "switch",
  20. "name": "多开关1",
  21. "default": false
  22. },
  23. "switchAnd2": {
  24. "type": "switch",
  25. "name": "多开关2",
  26. "default": false
  27. },
  28. "showInPanelAnd": {
  29. "type": "text",
  30. "name": "显示",
  31. "default": "多开关控制",
  32. "showInPanel": [
  33. [
  34. ".switchAnd1",
  35. "$eq",
  36. true
  37. ],
  38. [
  39. ".switchAnd2",
  40. "$eq",
  41. true
  42. ]
  43. ]
  44. },
  45. "switchOr1": {
  46. "type": "switch",
  47. "name": "交叉开关1",
  48. "default": false
  49. },
  50. "switchOr2": {
  51. "type": "switch",
  52. "name": "交叉开关2",
  53. "default": false
  54. },
  55. "showInPanelOr": {
  56. "type": "text",
  57. "name": "显示",
  58. "default": "交叉开关控制",
  59. "showInPanel": {
  60. "conditions": [
  61. [
  62. ".switchOr1",
  63. "$eq",
  64. true
  65. ],
  66. [
  67. ".switchOr2",
  68. "$eq",
  69. true
  70. ]
  71. ],
  72. "logicalType": "$or"
  73. }
  74. }