Skip to content

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

@gitAda16

Description

@gitAda16

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是否存在

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions