我如何定位此数组中的“数据”?
var waterBarData = {
labels: ["January", "February", "March", "April", "May", "June"],
datasets: [
{
label: "My Second dataset",
fillColor: "rgba(98,203,49,1.0)",
strokeColor: "rgba(98,203,49,0.8)",
highlightFill: "rgba(98,203,49,0.75)",
highlightStroke: "rgba(98,203,49,1)",
data: [28, 48, 40, 19, 86, 27]
}
]};
我的猜测如下,但似乎没有效果
waterBarData.datasets[data]
答案 0 :(得分:4)
datasets
是一个数组,因此您需要通过索引访问它:
waterBarData.datasets[0]['data'];
// or using dot notation
waterBarData.datasets[0].data;