我有代码来获取日期periode推送数组,如下所示:
var dari = $("#tglfrom").val();
var dateStart = new Date(dari);
var sampai = $("#tglto").val();
var dateEnd = new Date(sampai);
while (dateEnd >= dateStart) {
dateLoop.push( '{ title :"' + (dateStart.getMonth() + 1) + '/' + dateStart.getFullYear() + '"}');
var newDate = dateStart.setDate(dateStart.getMonth() + 1);
dateStart.setMonth(dateStart.getMonth() + 1);
}
然后我在Column上的DataTables上调用我的push数组,如下所示:
var Periode = dateLoop.join(', ');
$('#datatable1').DataTable( {
columns: [
{ title: "Name" },
{ title: "Position" },
{ title: "Office" },
{ title: "Extn." },
{ title: "Start date" },
Periode
]
});
但是当我跑步时,它表示错误:
未捕获的TypeError:无法使用'in'运算符在{中搜索'157' title:“1/2016”},{title:“2/2016”},{title:“3/2016”},{title :“4/2016”},{title:“5/2016”},{title:“6/2016”},{title :“7/2016”},{title:“8/2016”}
我做错了吗?