React框架开发问题总结

前端之家收集整理的这篇文章主要介绍了React框架开发问题总结前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
react-dom.js:18962Warning:Unknownprop`col`on<td>tag.Removethispropfromtheelement.Fordetails,see https://fb.me/react-unknown-prop
intd(createdbyListComponent)
intr(createdbyListComponent)
intable(createdbyListComponent)
indiv(createdbyListComponent)
inListComponent
indiv

解决办法:把col改成colSpan
<tdcolSpan='6'>/td>

react-dom.js:18962Warning:validateDOMNesting(...):<tr>cannotappearasachildof<table>.SeeListComponent>table>tr.Adda<tbody>toyourcodetomatchtheDOMtreegeneratedbythebrowser.
解决办法:<table>加增加子元素<tbody>

react-dom.js:18698UncaughtInvariantViolation:ExpectedonClicklistenertobeafunction,insteadgottypestring
解决办法: 预计OnClick侦听是一个函数,而不是字符串类型了
<spanclassName="first"onClick="{this.handleFirst}">首页</span>
改成
<spanclassName="first"onClick={this.handleFirst}>首页</span>


react.js:3801Warning:Eachchildinanarrayoriteratorshouldhaveaunique"key"prop.Checktherendermethodof`ListComponent`.See https://fb.me/react-warning-keysformoreinformation.
intr(createdbyListComponent)
inListComponent
indiv

解决办法:在循环array或iterator时,要给循环的标签增加一个key值。
[0,1].map((child,i)=>{
return(
<trkey={i}>
<td>item.time</td>

</tr>
);
})

react-dom.js:18698UncaughtInvariantViolation:noData.render():AvalidReactelement(ornull)mustbereturned.Youmayhavereturnedundefined,anarrayorsomeotherinvalidobject.
翻译: return里面的元素不完整 可能返回了undefined或数组或其他非法对象
render:function(){
lettext;
if(this.props.isShow){
text=(<divclassName="c999f16">{this.props.text}</div>);
}
console.log(text);
return({text});
}
解决办法:返回值应该包裹在一个元素内
return(<div>{text}</div>);
原文链接:https://www.f2er.com/react/305418.html

猜你在找的React相关文章