案例:React案例     状态:可编辑再运行    进入横版
x
 
1
<!DOCTYPE html>
2
<html>
3
  <head>
4
    <meta charset="UTF-8" />
5
    <title>W3xue教程 React 实例</title>
6
    <script src="/js/react0.14.7/react.js"></script>
7
    <script src="/js/react0.14.7/react-dom.js"></script>
8
    <script src="/js/react0.14.7/browser.min.js"></script>
9
  </head>
10
 <body>
11
    <div id="message" align="center"></div>
12
13
    <script type="text/babel">
14
      var Counter = React.createClass({
15
        getInitialState: function () {
16
          return { clickCount: 0 };
17
        },
18
        handleClick: function () {
19
          this.setState(function(state) {
20
            return {clickCount: state.clickCount + 1};
21
          });
22
        },
23
        render: function () {
24
          return (<h2 onClick={this.handleClick}>点我!点击次数为: {this.state.clickCount}</h2>);

 运行结果 
 北美留学生论坛