[英]Error on search filter for react ant design table
每當我在該字段上進行搜索時,表都會拋出TypeError: Cannot read property 'toString' of undefined[object Object]
。 我附上了代碼示例
誰能告訴我我做錯了什么?
當您的列中有空數據時,將發生錯誤。 例如,如果您的某一行缺少年齡值,而您嘗試搜索該列,則會拋出錯誤。 不確定如何修復。
是的,我遇到了同樣類型的錯誤,我解決了這個問題。
問題是:
{ onFilter: (value, record) => record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) }
修復 using if 條件后
{ onFilter: (value, record) => { if (record[dataIndex]) return record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.