我正在嘗試使用React庫來表示JSON格式的資料 勝利 這里是.
。組件的例子:
const data = [
{quarter: 1, earnings: 13000}。
{季度: 2, earnings: 16500},
{季度: 3, earnings: 14250}。
{季度: 4, earnings: 19000}。
];
class App extends React.component {
render() {
return (
<VictoryBar[/span
data={data}。
// data accessor for x values
x="quarter"
// data accessor for y values
y=" earnings"
/>
)
}
}
ReactDOM.render(<App/> , mountNode) 。
但是我從API獲得的資料是JSON格式
請注意資料的格式: const data = { "history" : [
{"quarter": 1, " earnings": 13000}。
{"季度": 2, " earnings": 16500},
{"季度": 3, " earnings": 14250}。
{"季度": 4, " earnings": 19000}.
]};
第一個片段中使用的是什么型別的陣列?
我怎樣才能從第二個片段中得到它呢?
uj5u.com熱心網友回復:
使用data.historical作為你組件中的陣列。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/307045.html
標籤:
下一篇:如何驗證geojson中的屬性鍵
