解决方案很简单,但目前还不明显。
每个输入都有一个属性,称为visibleRule
它完全满足了需要:控制它所附加的输入的可见性。所以在task.json
文件,在inputs
数组,可以这样做:
定义下拉菜单:
{
"name": "selectedOption",
"type": "pickList",
"label": "Options",
"options": {
"o1": "Option 1",
"o2": "Option 2",
"o3": "Option 3"
}
},
然后定义一些字段,如下所示:
{
"name": "test1",
"type": "string",
"label": "Option 1 test",
"visibleRule": "selectedOption = o1"
},
{
"name": "test2",
"type": "string",
"label": "Option 2 test",
"visibleRule": "selectedOption = o2"
},
Now the test1
仅当出现以下情况时才会显示输入o1
(选项 1)在selectedOption
落下。同样适用于test2
and o2
。两者都不test1
nor test2
如果显示selectedOption
is o3
.