lljj-x / vue-json-schema-form

基于Vue/Vue3,Json Schema 和 ElementUi/antd/iview3/naiveUi 等生成 HTML Form 表单,用于活动编辑器、h5编辑器、cms等数据配置;支持可视化生成表单Schema 。 Generate a form using Vue/Vue3, Json Schema and ElementUi/antdv/iview3/naiveUi
https://form.lljj.me/
Apache License 2.0
2.09k stars 428 forks source link

formUtils.getUiOptions处理fui:xxx 参数的时候报错 #371

Open gitAda16 opened 1 week ago

gitAda16 commented 1 week ago

vue和ui框架

vue2+elementui

问题描述

自定义field中调用formUtils.getUiOptions报错 如下 error.js:13 TypeError: Cannot read properties of undefined (reading 'split') at Br (vueJsonSchemaForm.esm.min.js:4:121853) at vueJsonSchemaForm.esm.min.js:4:123740 at Array.reduce (<anonymous>) at vueJsonSchemaForm.esm.min.js:4:123458 at Array.map (<anonymous>) at Jr (vueJsonSchemaForm.esm.min.js:4:123424) at Object.Zr [as getUiOptions] (vueJsonSchemaForm.esm.min.js:4:124489) at VueComponent.created (DnnInfoSchema.vue:326:1) at invokeWithErrorHandling (vue.runtime.esm.js:3017:1) at callHook$1 (vue.runtime.esm.js:4031:1)

如何复现

const fromSchema = {
      type: 'array',
      'ui:field': 'field-test',
      'ui:title': '信息列表',
      'fui:addable': (parent, root, prop) => {
        return !this.disabled
      },
      'fui:removable': (parent, root, prop) => {
        return !this.disabled
      },
      'ui:options': {
        sortable: false,
        showIndexNumber: true
      },
      items: {
        type: 'object',
        properties: {
          count: { type: 'number', title: '规格数量' }
        }
      }
    }
    const options = formUtils.getUiOptions({
      schema: fromSchema,
      uiSchema: {}
    })

期望的结果

发现原因是没有传curNodePath导致的,formUtils.js 中getUserUiOptions在处理fui:xxx 参数的时候没有判断curNodePath是否存在

lljj-x commented 5 days ago

应该是类型缺失了,我补充上