您可以使用 JavaScript 中的 Date 对象和相关方法来提取时间并赋值。以下是一个示例代码:

// 获取年月
var yearMonth = this.reportingPeriodDate.substring(0, 7);

// 设置开始日期为该月的第一天
var startDate = yearMonth + '-01';
this.form.incomePeriodDateStart = startDate;

// 获取下个月的第一天
var nextMonth = new Date(yearMonth + '-01');
nextMonth.setMonth(nextMonth.getMonth() + 1);
var lastDay = new Date(nextMonth.getTime() - 1000 * 60 * 60 * 24);

// 设置结束日期为该月的最后一天
var endDate = lastDay.toISOString().substring(0, 10);
this.form.incomePeriodDateEnd = endDate;

请注意,上述代码假设 this.reportingPeriodDate 的格式为 'YYYY-MM-DD'。如果格式不同,请根据实际情况进行调整。


原文地址: https://www.cveoy.top/t/topic/pmsM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录