js获取当前月份的前三个月 1.引入库 代码如下(示例): function getMonth(){ let newdate = new Date().setMonth(new Date().getMonth()-2) let Y = date.getFullYear() + '-'; let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1); let checkedDate = Y+M console.log(checkedDate ) // 2023-01 }