ant.design 3x table 設置了rowKey 仍然報Each child in a list should have a unique "key" prop.錯誤

記錄用ant.design 3x中遇到的一個奇葩錯誤。在使用ant 3.x table 進行開發時,已經設置了rowkey="id",但仍然報Each child in a list should have a unique "key" prop. 錯誤。嘗試許久,後發現是columns 配置問題,配置如下,columns 第一個元素必須設置dataIndex,否則即使設置了rowkey也會報錯。其他元素是否設置dataIndex沒有問題。不過第一個元素如果同時設置render,那麼設置dataIndex會使render失效。

const columns = [
      {
        title: '客戶類型',
        render: record => {
          return oUserType[record.userType]
        },
      },
      {
        title: '客戶名稱',
        dataIndex: 'userName',
      },
]

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章