您的位置:首页 > Web前端 > React

React框架开发问题总结

2016-11-23 16:42 661 查看
react-dom.js:18962 Warning: Unknown prop `col` on <td> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop    in td (created by ListComponent)    in tr (created by ListComponent)    in table (created by ListComponent)    in div (created by ListComponent)    in ListComponent    in div
解决办法:把col改成colSpan<td colSpan='6'>/td>
react-dom.js:18962 Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>. See ListComponent > table > tr. Add a <tbody> to your code to match the DOM tree generated by the browser.解决办法:<table>加增加子元素<tbody>
react-dom.js:18698 Uncaught Invariant Violation: Expected onClick listener to be a function, instead got type string解决办法:预计OnClick侦听是一个函数,而不是字符串类型了<span className="first" onClick="{this.handleFirst}">首页</span>改成<span className="first" onClick={this.handleFirst}>首页</span>

react.js:3801 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListComponent`. See https://fb.me/react-warning-keys for more information.    in tr (created by ListComponent)    in ListComponent    in div
解决办法:在循环array或iterator时,要给循环的标签增加一个key值。[0,1].map((child, i) => {                    return (                      <tr key={i}>                        <td>item.time</td>
                      </tr>                    );                  })
react-dom.js:18698 Uncaught Invariant Violation: noData.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.翻译:return里面的元素不完整 可能返回了undefined或数组或其他非法对象 render: function() {        let text;        if (this.props.isShow) {          text = (<div className="c999 f16">{this.props.text}</div>);        }        console.log(text);        return ({text});      }解决办法:返回值应该包裹在一个元素内return (<div>{text}</div>); 
react-dom.js:18109 Warning: Unknown DOM property readonly. Did you mean readOnly?警告:未知的DOM属性只读的。你的意思是只读的
    in input (created by App)
    in li (created by App)
    in ul (created by App)
    in div (created by App)
    in App (created by App)
    in App

readonly改成 readOnly
HTML 属性

这些标准的属性是被支持的:
accept acceptCharset accessKey action allowFullScreen allowTransparency alt
async autoComplete autoPlay cellPadding cellSpacing charSet checked classID
className cols colSpan content contentEditable contextMenu controls coords
crossOrigin data dateTime defer dir disabled download draggable encType form
formAction formEncType formMethod formNoValidate formTarget frameBorder height
hidden href hrefLang htmlFor httpEquiv icon id label lang list loop manifest
marginHeight marginWidth max maxLength media mediaGroup method min multiple
muted name noValidate open pattern placeholder poster preload radioGroup
readOnly rel required role rows rowSpan sandbox scope scrolling seamless
selected shape size sizes span spellCheck src srcDoc srcSet start step style
tabIndex target title type useMap value width wmode


react-dom.js:18109 Warning: Failed form propType: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`. Check the render method of `App`.

input 的value属性要改成 defaultValue
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: