Cannot use 'in' operator to search for 'value' in undefined


  ant 踩坑。 之  Cannot use 'in' operator to search for 'value' in undefined  at getValuePropValue (util.js:29)

 再使用多選   Select   組件時候報錯   如圖 

   

 

 

  原因是因為在 options 未渲染之前給 value 賦值了。

let children = List.length && List.map((item) => {
            return <Option name={item.userName} key={item.userId} value={item.userId} >{item.userName}</Option>
        })
                                 
 
  <Select
       {..Props}
        value={value}
        multiple
        style={{ width: '376px', marginRight: '10px' }}
       onChange={this.handleChange}
      optionFilterProp="children"
      labelInValue
>
      {children}
 </Select>
 

  將 紅色部分刪除掉 :

1 let children =  shapeExpertsList.map((item) => {
2             return <Option name={item.userName} key={item.userId} value={item.userId} >{item.userName}</Option>
3         }


免責聲明!

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



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM