标签:end like function turn creat onclick 处理 color ext
状态管理机制==?vuex?
就教程来看,还是不一样的,相当于vue实例里的data初始化,methods事件处理
var LikeButton = React.createClass({ getInitialState: function() { //state return {liked: false}; }, handleClick: function(event) { this.setState({liked: !this.state.liked}); }, render: function() { var text = this.state.liked ? ‘喜欢‘ : ‘不喜欢‘; return ( <p onClick={this.handleClick}>你<b>{text}</b>我。点我切换状态。</p> ); } }); ReactDOM.render( <LikeButton />, document.getElementById(‘app‘) );
标签:end like function turn creat onclick 处理 color ext
原文地址:http://www.cnblogs.com/hhweb/p/7211955.html