react的问题

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>子组件给父组件传值</title>
    <script src="https://cdn.bootcss.com/react/15.4.2/react.min.js"></script>
    <script src="https://cdn.bootcss.com/react/15.4.2/react-dom.min.js"></script>
      <script src="https://cdn.bootcss.com/babel-standalone/6.22.1/babel.min.js"></script>
  </head>
  <body>
    <div class="example"></div>
    <script type="text/babel">
        var Item = React.createClass({
          render:function(){
            return (
              <div>
              <input type="text" onChange={this.props.handleSonChange}/>
              </div>
            )
          }
        });

        var Box = React.createClass({
          getInitialState:function(){
            return {money:200};
          },
          handleSonChange:function(event){
            this.setState({money:event.target.value});
          },
          render:function(){

              <div>
                <span>{this.state.money}</span>
                <Item handleSonChange={this.handleSonChange()}/>
              </div>
          }
        })


        ReactDOM.render(
          <Box/>,
          document.getElementById('example')
        );
    </script>
  </body>
</html>

哪里写错了,报错信息我都看不懂

西兰花伟大炮
浏览 2352回答 3
3回答

Caballarii

react不是写在script标签里的,是使用npm和webpack构建的,createClass也是很老的写法了,去找个靠谱点的新教程吧

烦恼般若舟

1、首先,要把报错信息贴出来,别人才能帮你看问题。2、react版本更新快,建议用es6的写法写组件。3、用webpack构建,引入自己的组件,打包在一个js中,然后在自己的界面引入这个js
打开App,查看更多内容
随时随地看视频慕课网APP