控制台提示下面一段Warning,请问这个Warning该怎么解决呢
Use the defaultValue
or value
props on <select> instead of setting selected
on <option>.
下面是代码
<select>
{status.map((data,index) => {
if (STATE === index) {
return <option selected="true" key={index} value={index}>{data}</option>
}
return <option key={index} value={index}>{data}</option>
})
}
</select>
option的selected里不能被赋值,要赋值给select,如
这个select的value就是option被选中的value