<html> <head> <title></title> <meta charset="UTF-8"/> <script src="js/react.min.js" type="text/javascript" charset="utf-8"></script> <script src="js/react-dom.min.js" type="text/javascript" charset="utf-8"></script> <script src="js/browser.min.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div id="container"></div> </body> <script type="text/babel"> var Crud = React.createClass({ render: function(){ return ( <div> <h1>Hello {this.props.title}</h1> <p>{this.props.content}</p> </div> ); } }); ReactDOM.render( <div> <Crud title="world" content="aaaaaaaaaaa" /> <Crud title="react" content="bbbbbbbbbbb" /> </div>, document.getElementById(‘container‘) ); </script> </html>
多个标签需要一个根标签包裹起来
绑定参数 赋值 this.props.定义的名称
时间: 2024-11-09 03:06:54