我正在使用 jsonschema 来生成我们的表单并验证这些。
下面是一个示例 json:
{
"title": "Microsoft Account Request",
"readOnly": false,
"$schema": "http://json-schema.org/draft-04/hyper-schema",
"description": "Microsoft Azure Account Request Product Specification",
"properties": {
"product": {
"title": "Product",
"dataBinding": {"references": ["SPEC_ID#/properties/service"]},
"properties": {
"offers": {
"title": "Product Offers",
"propertyOrder": 1,
"type": "array",
"uniqueItems": true,
"format": "tabs",
"items": {
"title":"Product Offer",
"properties": {
"category": {
"title": "Category",
"readOnly": false,
"unique":true,
"strictProperties": true,
"enum": [
"Cloud Services",
"Virtual Machines",
"Azure App Service",
"Batch"
],
"options": {
"dependencies": [
{"id":"subcategoryAdd", "value":true}
]
},
"description": "Select category",
"propertyOrder": 1,
"type": "string"
},
"subcategory": {
"id":"subcategoryAdd",
"title": "Sub - Category",
"readOnly": false,
"strictProperties": true,
"description": "Select Sub-Category",
"options": {
"hide_display": true
},
"enum": [
"Build and Deployment",
"Application Insights"
],
"propertyOrder": 2,
"type": "string"
}
},
"type": "object"
}
}
},
"type": "object"
}
},
"type": "object"
}
和样本输出:
在输出表单中,我在其选择框中突出显示了子类别选项,应根据所选类别加载。
例如,如果我选择batch
子类别选项 a、b、c 应显示在子类别的选择框中,如果我选择Azure app service
子类别选项 d、e、f 应显示在子类别的选择框中。
我正在尝试dependencies
但徒劳无功。另外,我尝试通过使用watch
和来完成此操作,如此处enumSource
所述
任何帮助都是值得的。
谢谢!