最近六个月显示
vue调用方法
let month = new Date().getMonth() + 1
this.month = getRecentMonth(month)
js:
/**
* 根据当前月份获取其前六个月的月份
* @param month
* @return {Array|*}
*/
export function getRecentMonth(month) {
let arr = []
for(let i = 5;i > 0;i --) {
let sixMonth = month - i
if(sixMonth <= 0) {
sixMonth = 12 + sixMonth
}
arr.push(sixMonth + '月')
}
arr.push(month + '月')
return arr;
}