Skip to content

Commit 93bff8f

Browse files
committed
docs: 更新uiSchema、errorSChema 配置在schema参数中文档
1 parent c4e83c3 commit 93bff8f

File tree

2 files changed

+90
-22
lines changed

2 files changed

+90
-22
lines changed

packages/docs/docs/.vuepress/localesConfig/en.config.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ module.exports = {
2828
},
2929
// 顶部导航
3030
nav: [
31-
{
32-
text: 'Guide',
33-
ariaLabel: 'Guide',
34-
link: '/en/guide/'
35-
},
36-
{
37-
text: 'Type rules',
38-
ariaLabel: 'Type rules',
39-
items: [
40-
{ text: 'string', link: '/en/rules/string.md' },
41-
{ text: 'number', link: '/en/rules/number.md' },
42-
{ text: 'boolean', link: '/en/rules/boolean.md' },
43-
{ text: 'null', link: '/en/rules/null.md' },
44-
{ text: 'object', link: '/en/rules/object.md' },
45-
{ text: 'array', link: '/en/rules/array.md' },
46-
{ text: 'combining', link: '/en/rules/combining.md' },
47-
]
48-
},
31+
// {
32+
// text: 'Guide',
33+
// ariaLabel: 'Guide',
34+
// link: '/en/guide/'
35+
// },
36+
// {
37+
// text: 'Type rules',
38+
// ariaLabel: 'Type rules',
39+
// items: [
40+
// { text: 'string', link: '/en/rules/string.md' },
41+
// { text: 'number', link: '/en/rules/number.md' },
42+
// { text: 'boolean', link: '/en/rules/boolean.md' },
43+
// { text: 'null', link: '/en/rules/null.md' },
44+
// { text: 'object', link: '/en/rules/object.md' },
45+
// { text: 'array', link: '/en/rules/array.md' },
46+
// { text: 'combining', link: '/en/rules/combining.md' },
47+
// ]
48+
// },
4949
{ text: 'Playground', link: 'https://form.lljj.me' },
5050
{ text: 'Github', link: 'https://github.com/lljj-x/vue-json-schema-form' },
5151
],

packages/docs/docs/zh/guide/basic-config.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ export default {
9898
* 类型:`object`
9999
* 默认值:`{}`
100100

101-
用于配置表单展示样式,普通json数据,非`JSON Schema`规范
101+
> `0.0.16` 之后版本支持配置 `uiSchema``schema` 参数中 [点击查看](#uischema配置在schema中)
102+
103+
用于配置表单展示样式,普通json数据,非 `JSON Schema` 规范
102104

103105
:::tip
104106
* 配置数据结构和 `schema` 保持一致,所有的ui配置属性 `ui:` 开头
@@ -148,7 +150,46 @@ uiSchema = {
148150
>1. `ui:field` 自定义field组件参见这里 [自定义 field](/zh/guide/adv-config.html#自定义-field)
149151
>1. `ui:widget` 自定义widget组件参见这里 [自定义 widget](/zh/guide/adv-config.html#自定义-widget)
150152
151-
#### 如:重置表单widget样式
153+
154+
#### uiSchema配置在schema中
155+
156+
`0.0.16` 之后版本,`uiSchema` 所有配置都支持直接配置在 `schema` 参数中
157+
158+
* `uiSchema` 单独配置优先级大于 `schema` 中配置
159+
* 好处可以一份配置,不过会使 `schema` 不再是一份纯粹的 `JsonSchema` 文件,结合实际场景选择方案。
160+
161+
如下格式:
162+
```json
163+
{
164+
"title": "Demo",
165+
"type": "object",
166+
"ui:order": [
167+
"bio",
168+
"firstName"
169+
],
170+
"properties": {
171+
"firstName": {
172+
"type": "string",
173+
"title": "First name",
174+
"ui:placeholder": "请输入FirstName(配置在schema中)"
175+
},
176+
"bio": {
177+
"type": "string",
178+
"title": "Bio",
179+
"minLength": 10,
180+
"ui:options": {
181+
"type": "textarea",
182+
"placeholder": "请输入FirstName(配置在schema中)",
183+
"attrs": {
184+
"rows": 4
185+
}
186+
}
187+
}
188+
}
189+
}
190+
```
191+
192+
#### uiSchema配置演示:重置表单widget样式
152193
::: demo
153194
```html
154195
<template>
@@ -173,6 +214,23 @@ export default {
173214
schema: {
174215
type: 'object',
175216
properties: {
217+
firstName: {
218+
type: 'string',
219+
title: 'First name',
220+
'ui:placeholder': '请输入FirstName(配置在schema中)'
221+
},
222+
bio: {
223+
type: 'string',
224+
title: 'Bio',
225+
minLength: 10,
226+
'ui:options': {
227+
type: 'textarea',
228+
placeholder: 'placeholder(配置在schema中)',
229+
attrs: {
230+
rows: 4
231+
}
232+
}
233+
},
176234
inputText: {
177235
title: 'Input Text',
178236
type: 'string'
@@ -283,6 +341,8 @@ uiSchema = {
283341
* 类型:`object`
284342
* 默认值:`{}`
285343

344+
> `0.0.16` 之后版本支持配置 `errorSchema``schema` 参数中 [点击查看](#errorschema配置在schema中)
345+
286346
用于配置表单校验错误文案信息,普通json数据,非JSON Schema规范
287347

288348
数据配置和 `uiSchema` 保存一致,区别在于:
@@ -296,7 +356,13 @@ uiSchema = {
296356
> 注:errorSchema 为标准json数据,并非JSON Schema规范语法
297357
:::
298358

299-
例:重置表单错误信息
359+
#### errorSchema配置在schema中
360+
361+
`0.0.16` 之后版本,`errorSchema` 所有配置都支持直接配置在 `schema` 参数中。
362+
363+
> 使用格式类似 [uiSchema配置在schema中](#uischema配置在schema中)
364+
365+
errorSchema配置演示:重置表单错误信息
300366

301367
::: demo
302368
```html
@@ -331,7 +397,9 @@ export default {
331397
homePage: {
332398
type: 'string',
333399
format: 'uri',
334-
title: '个人主页'
400+
title: '个人主页',
401+
'err:required': '请输入个人主页地址(schema中配置)',
402+
'err:format': '请输入正确的Url地址(schema中配置)'
335403
},
336404
bio: {
337405
type: 'string',

0 commit comments

Comments
 (0)