alibaba / x-render

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

extra 属性传入html格式报错 #1450

Closed gdc1998 closed 8 months ago

gdc1998 commented 8 months ago

1.依赖仓库的版本(Dependencies versions)

2.问题描述(Bug description):extra 属性传入html格式报错

3.出现问题的 schema demo(Reproduction schema demo)

const schema = {
  properties: {
           test: {
              title: "test",
              type: "string",
              widget: "input",
              required: true,
              placeholder: '...',
              extra: <span>1</span>,
            },

          }
}

4.最小复现 demo(Reproduction demo)

form-render demo https://codesandbox.io/s/unruffled-flower-jl78h table-render demo https://codesandbox.io/s/sweet-euler-bdoty fr-generator demo https://codesandbox.io/s/s13sh

lhbxs commented 8 months ago

schema 本质上是 JSON 对象,所以不支持 extra 直接 配置 React Node,你可以 配置 extra: 'span>1' 这种 html 字符串 模版

如果是比较复杂的 ReactNode 的话,可以通过自定义组件,组件通过 widgets 属性对象传人,extra: { widget : '自定义组件名称'}, 和 widgets 进行匹配。