Ant Design Table 组件:`columns.customRender` 已被弃用,使用 `customCell` 替代
"Warning: columns.customRender return cell props is deprecated with perf issue, please use customCell instead." 在 basicColumns 中报这个错误是因为在 Ant Design Table 组件的 columns 配置中使用了 columns.customRender 属性,而该属性在新版本中已被废弃并且存在性能问题。为了解决这个问题,你需要使用 customCell 属性替代 customRender。\n\ncustomCell 属性的用法与 customRender 类似,它接收一个函数作为参数,该函数用于自定义单元格的渲染。你可以在这个函数中返回一个 React 节点来自定义单元格的内容。\n\n例如,如果你之前的代码是这样的:\n\njavascript\nconst columns = [\n {\n title: 'Name',\n dataIndex: 'name',\n customRender: (text, record) => <span>{record.name}</span>,\n },\n];\n\n\n你需要将其修改为:\n\njavascript\nconst columns = [\n {\n title: 'Name',\n dataIndex: 'name',\n customCell: (text, record) => <span>{record.name}</span>,\n },\n];\n\n\n通过这样的修改,你就可以避免在 basicColumns 中报 columns.customRender 属性被废弃的错误了。
原文地址: https://www.cveoy.top/t/topic/qtSR 著作权归作者所有。请勿转载和采集!