这里我试图显示一个简单的下拉列表。我知道getInitialState
也没有工作。我花了几个小时就可以了。你可以解释一下吗?谢谢。
var dropdown = React.createClass({
getInitialState:function() {
console.log('tr1');
return {
data2:[]
};
},
componentDidMount: function() {
console.log('tr2');
$.get(this.props.source, function(result) {
if (this.isMounted()) {
this.setState({
data2:result.data,
});
}
}.bind(this));
},
render:function() {
console.log('tr1');
console.log(this.state.data2);
return (
<div>
<h3>Select portfolio </h3> <br/>
<select onChange = {this.handleSelectChange}>
<option>any-select</option>
</select>
</div>
);
}
});
ReactDOM.render(<dropdown source="http://improwised.cgc.com/portfolios?token=yR225Y" />, document.getElementById('hello1'));