React 生命周期

react

<!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 >

var LifeComponent = React.createClass({
componentWillMount:function(){
console.log('准备插入');
console.log(this.refs.myParagraph);
},
componentDidMount:function(){
console.log('已经插入');
console.log(this.refs.myParagraph);
},
render:function(){
return <p ref='myParagraph'>Hello LifeCycle</p>
}
})

ReactDOM.render(
<LifeComponent/>,
document.getElementById('example')
)

</script>

</body>
</html>

以上是 React 生命周期 的全部内容, 来源链接: utcz.com/z/383624.html

回到顶部