var prices = [];
$.getJSON("http://www.asterank.com/api/asterank?query={%22neo%22:{%22$lt%22:%22Y%22},%20%22price%22:{%22$gt%22:100000000}}&limit=1000", function(data) {
$.each(data, function(key,value) {
prices.push(value.price);
});
});
var App = React.createClass({
render() {
return(
<div className="app">
<div>
{console.log("logging price array")}
{console.log(this.props.priceData)}
{this.props.priceData.map(p => <PriceColumn price={p} />)}
</div>
</div>
)
}
});
var PriceColumn = React.createClass({
render() {
return(
<div>
<h4>{this.props.price}</h4>
</div>
)
}
})
ReactDOM.render(<App priceData={prices}/>, document.getElementById('container'));
我試圖用json響應填充反應組件。這是「this.props.priceData」如何修復基於JSON響應的填充React組件?
Array[871]
[0 … 99]
0:
525905281.52797025
1:
604514917.0552349
2:
696637551.9520638
3:
875462960.8222823
4:
1267502400
5:
1332894080
6:
1467819274.5386994
7:
1498253120
8:
1703699200
9:
1743786240
10:
1864047360
11:
2725918720
12:
3191380043.7561345
13:
3652885251.1255836
14:
4587566603.506
每次我試圖訪問這個區域的數據點,我得到了一個未定義的執行console.log的一小段。謝謝您的幫助!
需要使用getIntialState方法,構造函數是es6類的語法方法 –
錯過了那個,謝謝我編輯過。 –
真棒,這使得總體感。謝謝 –