1
當我嘗試推送數組上的對象時,它將所有對象複製到上次推送的對象。推送對象時數組重複對象
var seriesArr = [];
var seriesDemo = {};
var seriesFinal = finalArr[0]
for (var o in finalArr[0]) {
seriesDemo.valueField = o;
seriesArr.push(seriesDemo);
}
OUTPUT:
[{"valueField":"amount[3]"},{"valueField":"amount[3]"},{"valueField":"amount[3]"},{"valueField":"amount[3]"}]
It should be like: [{"valueField":"amount[0]"},{"valueField":"amount[1]"},{"valueField":"amount[2]"},{"valueField":"amount[3]"}]
finalArr的值是多少? – Mairaj
忘記'seriesDemo'對象,並且喜歡'seriesArr.push({valueField:o});' – Redu