// 获取当前时间以及当前月的第一天 getCurrentDay(val) { var date = new Date() val ? date.setDate(1) : '' var year = date.getFullYear() var month = date.getMonth() + 1 var day = date.getDate() if (month < 10) { month = '0' + month } if (day < 10) { day = '0' + day } return year + '-' + month + '-' + day }, // 若结束时间是1号,那么取上个月的一号 beginTimeHandle() { const endTime = this.getCurrentDay() var endYear = endTime ? endTime.split('-')[0] : '' var endMonth = endTime ? endTime.split('-')[1] : '' var endDay = endTime ? endTime.split('-')[2] : '' return endDay === '01' ? endMonth === '01' ? endYear - 1 + '-' + '12' + '-' + endDay : (Number(endMonth) - 1) < 10 ? endYear + '-' + '0' + (Number(endMonth) - 1) + '-' + endDay : endYear + '-' + (Number(endMonth) - 1) + '-' + endDay : this.getCurrentDay(1) },