react官方tutorial心得

前端之家收集整理的这篇文章主要介绍了react官方tutorial心得前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
"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'))
原文链接:https://www.f2er.com/react/307330.html

猜你在找的React相关文章