React props传变量

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/react.js"></script>
<script src="js/react-dom.js"></script>
<script src="js/browser.min.js"></script>
</head>
<body>
<div id="example"></div> <script type="text/babel">
var LabelComponent = React.createClass({
render:function(){
return <label>{this.props.labelName}</label>
}
}) var InputComponent = React.createClass({
render:function(){
return <input type="text" placeholder={this.props.tips}/>
}
}) var ButtonComponent = React.createClass({
render:function(){
return <button>{this.props.buttonName}</button>
}
}) var LoginWindow = React.createClass({
render:function(){
return <div>
<LabelComponent labelName='用户名'/>
<InputComponent tips='请输入用户名'/>
<br/>
<LabelComponent labelName='密码'/>
<InputComponent tips='请输入密码'/>
<br/>
<ButtonComponent buttonName='注册'></ButtonComponent>
<ButtonComponent buttonName='登录'></ButtonComponent>
</div>
}
}) ReactDOM.render(
<LoginWindow/>,
document.getElementById('example')
) </script> </body>
</html>
上一篇:pymysql 简单操作数据库


下一篇:JavaScript高级程序设计44.pdf