<script type="text/babel">
class List extends React.Component {
state = {
objects: ['1', '2', '3']
};
render() {
return(<div> objects[1] </div>)
}
}
错误:browser.min.js:41 Uncaught SyntaxError:embedded:Unexpected token(4:18)
2 | class List extends React.Component {
3 |
> 4 | state = {
| ^
5 | objects: ['1', '2', '3']
6 | };
我无法理解((
答案 0 :(得分:0)
<script type="text/babel">
class List extends React.Component {
constructor(props) {
this.state = {
objects: ['1', '2', '3']
};
}
render() {
return(<div> {this.state.objects[1]} </div>)
}
}