Dependencies 如何使alpaca条件依赖项使用函数而不是数组?
我有一个带有数组的模式。数组中的每个值都有一个已知的前缀。不使用数组,是否可以使用函数/条件检查某个字段中的值,以确定该值是否具有已知前缀并导致显示从属字段 这个问题()与我面临的问题有关(如何获取和检查函数中字段的值) 注:一个站点可能被划分为多种类型,因此值上的Dependencies 如何使alpaca条件依赖项使用函数而不是数组?,dependencies,conditional-statements,alpacajs,Dependencies,Conditional Statements,Alpacajs,我有一个带有数组的模式。数组中的每个值都有一个已知的前缀。不使用数组,是否可以使用函数/条件检查某个字段中的值,以确定该值是否具有已知前缀并导致显示从属字段 这个问题()与我面临的问题有关(如何获取和检查函数中字段的值) 注:一个站点可能被划分为多种类型,因此值上的TypePrefix0 这就是目前存在问题的代码: "schema": { "properties": { "tpl": { "type":"string" }, "site": { // optionTree
TypePrefix0
这就是目前存在问题的代码:
"schema": {
"properties": {
"tpl": { "type":"string" },
"site": { // optionTree
"type":"string",
"title":"Site",
"required": true
},
"sourceType": {
"type":"string",
"title":"Source Type",
"enum":['area','group'],
},
"dataType": {
"type":"string",
"title":"Data Type",
"enum":['people','vehicles', '*']
},
},
"dependencies": {
"dataType": ["sourceType", "site"]
}
},
"options": {
"fields: { // reduced to relevant parts
"dataType": {
"dependencies: {
"sourceType": "group",
// site values shown here are not actual values used in production
"site": ["TypePrefix0.site0", "TypePrefix0.site1", "TypePrefix0.site2", /*...*/]
// how do/can I replace the array with a function/condition:
// (site.value.startsWith("TypePrefix0.")) : true
}
}
}
}
不要使用
optiontree
控件,而是将其拆分为三个select
控件。(第一个是站点类型。其他两个都是特定类型的站点。)根据第一个站点的特定值进行第二个和第三个选择。这样,您就不用在第二个和第三个select控件的值中添加前缀。与其使用optiontree
控件,不如将其拆分为三个select
控件。(第一个是站点类型。其他两个都是特定类型的站点。)根据第一个站点的特定值进行第二个和第三个选择。这样,您就不用在第二个和第三个选择控件的值中添加前缀了。虽然您已经解决了这个问题,但我还是找到了链接问题的解决方案,这可能会有所帮助:虽然您已经解决了这个问题,但我找到了链接问题的解决方案,因此可能会有所帮助: