继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

慕课网react入门课程代码

杨小亮灬
关注TA
已关注
手记 1
粉丝 1
获赞 6

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>imooc-react入门课程代码</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<style>
body{
color:#f00;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/jsx">
var TestClickComponent=React.createClass({
handleClick:function (event) {
var tipE=React.findDOMNode(this.refs.tip);
if(tipE.style.display==='none'){
tipE.style.display='inline';
}else{
tipE.style.display='none'
}
event.stopPropagation();

       },
       render:function () {
           return(

<div>
<button onClick={this.handleClick}>显示|隐藏</button><span ref="tip">测试点击</span>

               </div>

);
}
});
var TestInputComponent=React.createClass({
getInitialState:function () {
return{
inputContent:''
}
},
changeHandler:function (event) {
this.setState({
inputContent:event.target.value
});
event.stopPropagation();
event.preventDefault();
},
render:function () {
return(
<div>
<input type="text" onChange={this.changeHandler}/><span>{this.state.inputContent}</span>
</div>
)
}
});
React.render(
<div>
<TestClickComponent/>
<br/><br/>
<TestInputComponent/>
</div>,
document.getElementById('container'));
</script>
</body>
</html>

打开App,阅读手记
3人推荐
发表评论
随时随地看视频慕课网APP