0
<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 |             };

我无法理解((

4

1 回答 1

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>)
        }
    }
于 2016-11-14T10:41:07.097 回答