【react】報錯Need at least a key or a value or a label (only for OptGroup) for [object Object]


antd  select  組件 option value為空了 

找到賦值option打印原始數據 

 

 原因:后台返回了一條無用的數據,針對這種 錯誤 一般返回數據后台會直接過濾 ;為了規避這種無用數據造成前端報錯;前端增加判斷,過濾數據;

 let hospSelect = []
                    for (var i = 0; i < res.Hosp.length; i++) {
                        if(res.Hosp[i].id&&res.Hosp[i].descripts) hospSelect.push(<Option key={res.Hosp[i].id} alias={res.Hosp[i].descriptsSPCode}>{res.Hosp[i].descripts}</Option>)
                    }
                    this.setState({
                        hospSelect,
                    })


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 Mysql8報錯:ERROR 1227 (42000): Access denied; you need (at least one of) the SYSTEM_USER privilege(s) for this operation 取出List >里面Map的key:value值 python報錯:Exception Value:can only concatenate str (not "bytes") to str Vue報錯:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#‘的解決方法 [one day one question] webpack 打包報錯 Cannot assign to read only property 'exports' of object '#' vue運行報錯error:Cannot assign to read only property 'exports' of object '#' Map 通過key取value值時,取出的LinkedHashMap轉換為實體對象 'dict_values' object does not support indexing, Python字典dict中由value查key Vue報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解決方法 Vue 使用自定義組件時報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#'
 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM