<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>state2</title>
<script src="build/browser.min.js"></script>
<script src="build/react.js"></script>
<script src="build/react-dom.js"></script>
<script type="text/babel">
var ClickApp = React.createClass({
getInitialState:function(){
return {
clickCount:0,
};
},
handleClick:function(){
this.setState({
clickCount:this.state.clickCount+1,
});
},
render:function(){
return (
<div>
<h2>点击下面按钮</h2>
<button onClick={this.handleClick}>点击我</button>
<p>你一共点击了:{this.state.clickCount}</p>
</div>
);
}
});
ReactDOM.render(<ClickApp/>,
document.getElementById('app'),
function(){
console.log('渲染完成啦')
});
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>