[英]How to create a function in typescript
1.I have the data like below: 1.我有如下数据:
[{
"BatchConfigName": "End1",
"EndDateTime": "2019-01-06T11:10:00"
},
{
"BatchConfigName": "End2 - Non-Gas",
"EndDateTime": "2019-01-07T05:54:00"
},
{
"BatchConfigName": "Secure",
"EndDateTime": "2019-01-07T04:48:00"
}
}
i want to create the typescript function that assign this data like我想创建分配此数据的打字稿函数,例如
var datawebsiteViewsChart = { labels: ['End1', 'End2 - Non-Gas', 'Secure'], series: [ [11: 10, 05: 54, 04: 48] ] };
None没有任何
function map(data) {
const labels = [];
const series = [];
for (itemKey of data) {
labels.push(itemKey);
series.push(data[itemKey]);
}
return {
labels,
series
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.