Warning: Invalid DOM property `for`. Did you mean `htmlFor`?
在react中label标签不能使用for关键字
报错警告:
Warning: Invalid DOM property for
. Did you mean htmlFor
?
错误写法:
<div className="radioItem">
<input type="radio" id="curEntrust" />
<label for="curEntrust">当前委托</label>
</div>
应改为:
<div className="radioItem">
<input type="radio" id="curEntrust" />
<label htmlFor="curEntrust">当前委托</label>
</div>
在使用React时,不能在JSX中使用for关键字,因为这是一个javascript关键字(JSX是javascript,所以像for和class这样的词不能使用,因为它们有其他特殊含义!)
作者:EchoHi
链接:https://www.jianshu.com/p/fb0acf2538d1
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
还没有评论,来说两句吧...