我尝试使用JS时刻更改日期。我该怎么做data child[index-1].childEndDate = childStartDate -1?
例如:
if child[1].childEndDate = 03/22/2019,
child[0].childStartDate = 03/21/2019
Run Code Online (Sandbox Code Playgroud)
child[index-1].childEndDate = childStartDate -1不起作用。我认为childStartDate-与MomentJS搭配使用不正确
childAutoChangeData(start, end, child, index) {
const childStartDate = moment(start);
const childEndDate = moment(end);
if (index > 0 && !end.isSame(child[index].childStartDate + 1)) {
child[index - 1].childEndDate = start-1;
}
return child;
}
Run Code Online (Sandbox Code Playgroud) 我试图将日期设为空。因此,当我单击清除按钮时,我试图将它们全部设置为0。
this.clear = function () {
_this.newQuarters.forEach(function (_value, index) {
_value.startDate = 0;
_value.endDate = 0;
_value.suppressAllocation = false;
_value.quarters.forEach(function (_childValue, index) {
_childValue.startDate = 0;
_childValue.endDate = 0;
_childValue.suppressAllocation = false;
});
});
};
}
Run Code Online (Sandbox Code Playgroud)
在那之后,我试图从其他函数添加0。
this.newQuarters.forEach(function (_value, index) {
var startDate = moment(_value.startDate);
Run Code Online (Sandbox Code Playgroud)
但是,它将显示startDate = 1969年12月31日,星期三。请帮助我查找所有日期是否为空。