作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 react 组件中编写了以下方法,一切正常
render() { return (
<div>
<div>
<AppHeader x = {this.state.x} y = {this.state.y} />
<Button id = {0} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {1} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {2} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {3} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
</div>
<div>
<ScoreBoard correct={this.state.correct} incorrect={this.state.incorrect} />
</div>
</div>
)}
但是 2 个 div 出现在另一个上面。我将代码更改为
render() { return (
<div>
<div style='float:left'>
<AppHeader x = {this.state.x} y = {this.state.y} />
<Button id = {0} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {1} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {2} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
<Button id = {3} x = {this.state.x} y = {this.state.y} answerKey = {this.state.answerKey} handleClick={this.handleClick} />
</div>
<div style='float:right'>
<ScoreBoard correct={this.state.correct} incorrect={this.state.incorrect} />
</div>
</div>
)}
但是一旦我将样式左右放置。我收到错误
Invariant Violation: Minified React error #62; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=62&args[]=%20This%20DOM%20node%20was%20rendered%20by%20%60Quiz%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
我根本不明白这个错误..为什么 style='float:left' 这么重要?
最佳答案
Style 需要一个 Javascript 样式对象。您提供的是一个字符串。
<div style={{float: 'right'}}>
<ScoreBoard correct={this.state.correct} incorrect={this.state.incorrect} />
</div>
关于reactjs - 不变违规 : Minified React error #62,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48897903/
我是一名优秀的程序员,十分优秀!