为了账号安全,请及时绑定邮箱和手机立即绑定

慕课网react入门课程代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>imooc-react入门课程代码</title>
<script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="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>

点击查看更多内容
3人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消