el-data-table icon indicating copy to clipboard operation
el-data-table copied to clipboard

tableAttrs里添加elementui table的row-key属性不生效

Open Skura23 opened this issue 3 years ago • 0 comments

Describe the bug

tableAttrs里添加elementui table的row-key属性不生效

Screenshots

-

To Reproduce

Steps to reproduce the behavior: elementui el-table文档:

支持树类型的数据的显示。当 row 中包含 children 字段时,被视为树形数据。渲染树形数据时,必须要指定 row-key。支持子节点数据异步加载。设置 Table 的 lazy 属性为 true 与加载函数 load 。通过指定 row 中的 hasChildren 字段来指定哪些行是包含子节点。children 与 hasChildren 都可以通过 tree-props 配置。

1, 在数据里带有children字段的情况下, 加入row-key设置:

// 模拟数据
onResponse: (result) => {
  const data = [{
    id: 2,
    parentId: 0,
    nameStr: '111',
    childrenExist: true,
    children: [
      {
        id: 3,
        parentId: 2,
        nameStr: '222',
        childrenExist: false,
      }
    ]
  }]
  return {
    data,
    total: 2
  }
  },

tableAttrs: {
  'row-key': 'id'
},

2, 仍报错 Error: for nested data item, row-key is required.

Expected behavior

支持elementui el-table原生的树功能

environment information

  • Version [e.g. 22] "@femessage/el-data-table": "^1.23.0", "element-ui": "2.13.2",
  • OS: win10
  • Browser chrome

Skura23 avatar Dec 23 '21 09:12 Skura23