<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="js/react.js"></script> <script src="js/react-dom.js"></script> <script src="js/browser.min.js"></script> </head> <body> <div id="example_1"></div> <div id="example_2"></div> <script type="text/babel"> var A = React.createClass({ getInitialState:function(){ return {count:0}; }, render:function(){ return <div>{this.state.count}</div> }, eventClick:function(){ this.setState({ count: this.state.count+1, }) } }); ReactDOM.render(<div> <A class="a"/> <input type="button" onClick={A.eventClick}/> </div>, document.getElementById("example_1") ); </script> </body> </html>
付费偷看金额在0.1-10元之间
写法不正确,你的组件是渲染到A上了,和下面的input 没关系。
onClick={A.eventClick}?直接onClick={eventClick}
一周热门 更多>