alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
7.05k stars 997 forks source link

TypeError: Cannot read properties of undefined #1363

Closed xyy7260 closed 1 year ago

xyy7260 commented 1 year ago

代码

{
  "type": "object",
  "title": "meta",
  "properties": {
    "hospital": {
      "param": "hospital",
      "title": "hospital",
      "type": "string",
      "labelWidget": "CustomLabel",
      "descWidget": "CustomDesc",
      "required": true,

      "description": "hospital.description",
      "tooltip": "hospital.tooltip",
      "extra": "hospital.extra",
      "props": {}
    },

    "blood": {
      "param": "blood",
      "title": "blood",
      "type": "object",
      "properties": {
        "history": {
          "param": "history",
          "title": "history",
          "type": "string",
          "props": {
            "options": [
              {
                "label": "history_0",
                "value": "history_0"
              },
              {
                "label": "history_1",
                "value": "history_1"
              },
              {
                "label": "history_2",
                "value": "history_2"
              }
            ]
          }

        },
        "kou": {
          "param": "kou",
          "title": "kou",
          "type": "string",

          "hidden": "{{!formData.blood.history || ['history_1','history_2'].includes(formData.blood.history) }}"

        }
      }
    }

  }
}
<FormRender
          validateMessages={validateMessages}
          form={form}
          scrollToFirstError
          schema={metaInfo?.Schemas[0]?.JsonSchema}

        />

将上面的json 复制到这里然后 打开控制台 选择或者输入就会有下面提示,


 TypeError: Cannot read properties of undefined (reading 'history')
    at eval (eval at Ir (shared-YfxVLdtYwLV0yUSoRAWChWxNrE_.03070d46.async.js:3:18), <anonymous>:4:54)
    at Ir (shared-YfxVLdtYwLV0yUSoRAWChWxNrE_.03070d46.async.js:3:29)
    at shared-YfxVLdtYwLV0yUSoRAWChWxNrE_.03070d46.async.js:3:1190
    at Array.every (<anonymous>)
    at Or (shared-YfxVLdtYwLV0yUSoRAWChWxNrE_.03070d46.async.js:3:1154)
    at shared-YfxVLdtYwLV0yUSoRAWChWxNrE_.03070d46.async.js:3:1317
    at En (dumi__theme__layouts__DocLayout.304fdb45.async.js:229:17838)
    at a.onStoreChange (dumi__theme__layouts__DocLayout.304fdb45.async.js:229:20050)
    at dumi__theme__layouts__DocLayout.304fdb45.async.js:229:35953
    at Array.forEach (<anonymous>) []
lhbxs commented 1 year ago

https://xrender.fun/playground

我放到这个里面运行看,没有问题呢,是不是版本锁死了?更新到 2.x 最新版看看

xyy7260 commented 1 year ago

@lhbxs 你要选择下拉框后才会出现这样的问题 TypeError: Cannot read properties of undefined (reading 'history')

xyy7260 commented 1 year ago

不是复制进去就会显示了 老表