【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刪除。



猜您在找 RedisTemplate 報錯 Unexpected token (VALUE_NUMBER_INT), expected VALUE_STRING: need JSON String that contains type id (for subtype of java.lang.Object) at [Source: (byte[])" json 解析不出來 (No string key for value in object around character 6) create-react-app 遇到問題 TypeError: Cannot assign to read only property 'jsx' of object '#' 取出List >里面Map的key:value值 Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' Object prototype may only be an Object or null: undefined Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' vue 項目啟動報錯:Cannot assign to read only property 'exports' of object '#' Vue報錯:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#‘的解決方法
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM