createBeginDate(){
var date = new Date();
date.setMonth(date.getMonth()-3);
date.toLocaleDateString()
var y = date.getFullYear()
var m = date.getMonth() + 1
m = m < 10 ? ('0' + m) : m
var d = date.getDate()
d = d < 10 ? ('0' + d) : d
const time = y + '-' + m + '-' + d
return time;
}
可以无视闰年或者二五月份的问题,亲测了。可以在var date = new Date();中传入时间进行测试 比如var date = new Date('2020-02-29')这种;