Comments (1)
对首次匹配结果做特殊处理,兼容配置 required
来区分 anyOf 的场景,如下数据可正常编辑匹配:
{
"type": "object",
"required": [
"age"
],
"anyOf": [
{
"ui:showTitle": true,
"title": "First method of identification",
"required": [
"lastName"
],
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": "Chuck"
},
"lastName": {
"type": "string",
"title": "Last name"
}
}
},
{
"ui:showTitle": true,
"title": "Second method of identification",
"properties": {
"firstName": {
"type": "string",
"title": "First name"
},
"idCode": {
"type": "string",
"title": "ID code",
"default": "Default id"
}
}
}
]
}
针对anyOf 数据回写的场景,更保险的方式应该 结合 const
一起使用,const 可以约定包含的值必须为该结果,如下:
也可参见:https://form.lljj.me/#/demo?type=AnyOf%28%E8%81%94%E5%8A%A8%29
新增一个 type 字段,配置 const 和 default 判定当前的选中项,同时可以配置ui:hidden 来隐藏该项。
{
"type": "object",
"anyOf": [
{
"ui:showTitle": true,
"title": "First method of identification",
"properties": {
"type": {
"ui:hidden": true,
"type": "string",
"default": "userName",
"const": "userName"
},
"firstName": {
"type": "string",
"title": "First name",
"default": "Chuck"
},
"lastName": {
"type": "string",
"title": "Last name"
}
}
},
{
"ui:showTitle": true,
"title": "Second method of identification",
"properties": {
"type": {
"ui:hidden": true,
"type": "string",
"default": "id",
"const": "id"
},
"firstName": {
"type": "string",
"title": "First name"
},
"idCode": {
"type": "string",
"title": "ID code",
"default": "Default id"
}
}
}
]
}
from vue-json-schema-form.
Related Issues (20)
- vue3 antDv中textarea不生效,显示的是input输入框 HOT 1
- 表单设计器啥时候支持vue3? HOT 1
- help to show custom element HOT 2
- Customize data inside n-select HOT 4
- 功能建议:支持表单项搜索(过滤)的功能
- 项目下载后无法运行
- 按需引入antdv,组件为什么不能展示 HOT 1
- 适配vue2+tdesign时input输入框无效
- Get index of array HOT 2
- 使用oneOf 点击保存时总是提示错误 HOT 1
- 在vue2-form-core中formItem的校验规则validator只能使用callback的方式 HOT 3
- array类型的参数,items使用anyOf回显问题 HOT 4
- 请问有vue3版本的活动编辑器吗
- 同样的Schema在vue2版本可以正常使用,在vue3版本不可以 HOT 1
- 下拉框提示 应当是预设值定的枚举值之一 HOT 1
- 数组操作的一些功能支持 HOT 1
- antdv4.x 的样式兼容, 内含复现demo HOT 3
- vue2+element 下拉框 单选框等无法渲染,设置enum和'ui:enumOptions'都无法正确展示 HOT 6
- select 下拉框怎么绑定值为对象 HOT 4
- customrule 自定义校验 成功我希望就校验成功,但是如果schema校验失败会即使自动义校验成功也会校验失败。希望自定义校验结果最高 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-json-schema-form.