embedded:意外的令牌。反应。

时间:2016-11-14 10:25:37

标签: javascript django reactjs jsvc

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

我无法理解((

1 个答案:

答案 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>)
        }
    }