首页 > 代码库 > React componentDidMount
React componentDidMount
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="http://www.mamicode.com/js/react.js"></script>
<script src="http://www.mamicode.com/js/react-dom.js"></script>
<script src="http://www.mamicode.com/js/browser.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
var LifeComponent = React.createClass({
componentDidMount:function(){
setInterval(
function(){
var nowValue = http://www.mamicode.com/this.state.opacityValue;
nowValue+=0.1;
if(nowValue > 1)
{
nowValue = http://www.mamicode.com/0;
}
this.setState({opacityValue:nowValue},function(){
console.log(this.state.opacityValue);
});
}.bind(this),100
)
},
getInitialState:function(){
return {opacityValue:0}
},
render:function(){
return <div style={{opacity:this.state.opacityValue}}>
Hello LifeCycle
</div>
}
})
ReactDOM.render(
<LifeComponent/>,
document.getElementById(‘example‘)
)
</script>
</body>
</html>
React componentDidMount
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。