baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.4k stars 2.52k forks source link

table-view的单元格, 数据源必须是一个组件 #11054

Open yanquer opened 1 month ago

yanquer commented 1 month ago

table-view 的单元格是一个列表时,

  {"tds": [{
    "body": [
      {
          "type": "list",
          "source": "${viewData.options.includes|strToListArray}",
          "listItem": {
              "subTitle": "$desc"
          },
      },
    ]
  }]}

渲染的时候会遇到报错(不过渲染可以成功)

[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[ListRenderer.render()]' Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

测试后估计是 source 的数据源对非显示组件的支持有问题, 可能内部觉得没法监听到状态?

暂时使用辅助组件解决

  {"tds": [{
    "body": [
      {
          "type": "input-text",
          "value": "${viewData.options.includes|strToListArray}",
          "name": "tmpTpl",
          "visible": false,
      },
      {
          "type": "list",
          "source": "$tmpTpl",
          "listItem": {
              "subTitle": "$desc"
          },
      },
    ]
  }]}

ps: 目前好些问题貌似都只能使用辅助组件解决