我正在尝试将今天的日期分配给contVfrmDate并使用值/日期来增加下一个键的 x 天数?可以在对象/字典内完成吗?如果是,怎么办?
const ccCustInfo = {
cropConsultant: 'Test this',
customerName: 'Customer',
customerBranch: 'MULBERRY ',
shippingAddress:'address',
contractType: 'SKU',
contVfrom: 'Contract Valid From',
contVto: 'Contract Valid To',
internalNotes: 'Internal Notes',
contVfrmDate: (new Date(Date.now()).toLocaleString().split(',')[0]),
contVtoDate: contVfrmDate.setDate(contVfrmDate.getDate() + 5)
}
在 Chrome 控制台中,我看到此错误。
Uncaught ReferenceError: contVfrmDate is not defined
at <anonymous>:11:24
找到了另一个简单的解决方案,因为to date默认为 8 天。
contVtoDate: (new Date(Date.now() + (8 /*days*/ * 86400000 /*ms per day*/)).toLocaleString().split(',')[0])}
const ccCustInfo = {
cropConsultant: 'Test this',
customerName: 'Customer 5K FARMS',
customerBranch: 'MULBERRY FL',
shippingAddress:'3010',
contractType: 'SKU',
contVfrom: 'Contract Valid From',
contVto: 'Contract Valid To',
internalNotes: 'Internal Notes',
contVfrmDate: (new Date(Date.now()).toLocaleString().split(',')[0]),
contVtoDate: (new Date(Date.now() + (8 /*days*/ * 86400000 /*ms per day*/)).toLocaleString().split(',')[0])
}
慕村9548890
相关分类