File tree Expand file tree Collapse file tree 2 files changed +34
-25
lines changed
packages/lib/src/JsonSchemaForm Expand file tree Collapse file tree 2 files changed +34
-25
lines changed Original file line number Diff line number Diff line change @@ -160,20 +160,24 @@ export function getWidgetConfig({
160160
161161 const {
162162 widget,
163- title,
163+ title : label ,
164164 labelWidth,
165165 description,
166- attrs,
166+ attrs : widgetAttrs ,
167+ class : widgetClassName ,
168+ style : widgetStyle ,
167169 emptyValue,
168170 ...uiProps
169171 } = widgetConfig ;
170172
171173 return {
172174 widget,
173- label : title ,
175+ label,
174176 labelWidth,
175177 description,
176- attrs,
178+ widgetAttrs,
179+ widgetClassName,
180+ widgetStyle,
177181 emptyValue,
178182 uiProps
179183 } ;
Original file line number Diff line number Diff line change @@ -41,6 +41,17 @@ export default {
4141 } ,
4242 widget : {
4343 type : [ String , Function , Object ] ,
44+ default : null
45+ } ,
46+ required : {
47+ type : Boolean ,
48+ default : false
49+ } ,
50+ // 解决 JSON Schema和实际输入元素中空字符串 required 判定的差异性
51+ // 元素输入为 '' 使用 emptyValue 的值
52+ emptyValue : {
53+ type : null ,
54+ default : undefined
4455 } ,
4556 // 部分场景可能需要格式化值,如vue .number 修饰符
4657 formatValue : {
@@ -69,18 +80,18 @@ export default {
6980 type : String ,
7081 default : ''
7182 } ,
72- required : {
73- type : Boolean ,
74- default : false
83+ // attrs
84+ widgetAttrs : {
85+ type : Object ,
86+ default : ( ) => ( { } )
7587 } ,
76- // 解决 JSON Schema和实际输入元素中空字符串 required 判定的差异性
77- // 元素输入为 '' 使用 emptyValue 的值
78- emptyValue : {
79- type : null ,
80- default : undefined
88+ // className
89+ widgetClassName : {
90+ type : Object ,
91+ default : ( ) => ( { } )
8192 } ,
82- // attrs
83- attrs : {
93+ // style
94+ widgetStyle : {
8495 type : Object ,
8596 default : ( ) => ( { } )
8697 } ,
@@ -120,12 +131,6 @@ export default {
120131 render ( h ) {
121132 const self = this ;
122133
123- const {
124- class : className ,
125- style,
126- ...uiProps
127- } = self . uiProps ;
128-
129134 // 判断是否为根节点
130135 const isRootNode = isRootNodePath ( this . curNodePath ) ;
131136
@@ -206,14 +211,14 @@ export default {
206211 self . widget ,
207212 {
208213 props : {
209- ...uiProps ,
214+ ...self . uiProps ,
210215 value : this . value , // v-model
211216 } ,
212- style,
213- class : className ,
217+ style : self . widgetStyle ,
218+ class : self . widgetClassName ,
214219 attrs : {
215- placeholder : uiProps . placeholder , // 兼容placeholder配置在 外层或者attr内
216- ...self . attrs
220+ placeholder : self . uiProps . placeholder , // 兼容placeholder配置在 外层或者attr内
221+ ...self . widgetAttrs
217222 } ,
218223 on : {
219224 input ( event ) {
You can’t perform that action at this time.
0 commit comments