react.js-11-网络请求

前端之家收集整理的这篇文章主要介绍了react.js-11-网络请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

demo git地址:https://git.oschina.net/tomcode/reactdemo.git










var UserGist = React.createClass({
getInitialState: function() {
return {
username: ”,
lastGistUrl: ”
};
},

componentDidMount: function() {
$.get(this.props.source,function(result) {
var lastGist = result[0];
if (this.isMounted()) {
this.setState({
username: lastGist.owner.login,
lastGistUrl: lastGist.html_url
});
}
}.bind(this));
},

render: function() {
return (


{this.state.username}’s last gist is here.

);
}
});

ReactDOM.render(,document.body );

原文链接:https://www.f2er.com/react/307070.html

猜你在找的React相关文章