// 创建一个空数组来存储日期
var daysInMonth = [];
// 获取当前日期对象
var currentDate = new Date();
// 获取当前月份
var currentMonth = currentDate.getMonth();
// 设置日期对象为当前月的第一天
currentDate.setDate(1);
// 循环增加日期直到月份变化,记录每一天
while (currentDate.getMonth() === currentMonth) {
var day = currentDate.getDate();
daysInMonth.push(day);
currentDate.setDate(currentDate.getDate() + 1);
}
console.log(daysInMonth, '天数');
daysInMonth.forEach((item, index) => {
var obj = {
label: item + '号',
value: item
}
this.dateList.push(obj);
});
js获取当前月份有多少天,并将这些天数组成一个数组(整理)
猜你喜欢
转载自blog.csdn.net/qq_38881495/article/details/131569441
今日推荐
周排行