react官方tutorial心得
发布时间:2020-12-15 04:42:16 所属栏目:百科 来源:网络整理
导读:"use strict";var React = require('react');var ReactDOM = require('react-dom');class Counter extends React.Component { constructor(props) { super(props); this.state = {count: 0}; } tick() { this.setState({count: this.state.count + 1}); } re
"use strict"; var React = require('react'); var ReactDOM = require('react-dom'); class Counter extends React.Component { constructor(props) { super(props); this.state = {count: 0}; } tick() { this.setState({count: this.state.count + 1}); } render() { return ( <div className="text-center"> <h1> Clicks: {this.state.count} </h1> <button className="btn btn-info" onClick={this.tick.bind(this)}>加1</button> </div> ) } } ReactDOM.render(<Counter />,document.getElementById('app')) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |