JavaScript util
统计两个日期之间的月份
getMonths(date_one,date_tow){
let one = date_one.split('-')
let tow = date_tow.split('-')
const y2 = parseInt(tow[0])
let y1 = parseInt(one[0])
const m2 = parseInt(tow[1])
let m1 = parseInt(one[1])
let count = ( y2 - y1 ) * 12 + m2 - m1
for (let i = 0 ;count >= 0;){
if (m1 <= 12){
m1 = m1<10?('0'+m1):m1
let temp = y1 + '-' + m1
// this.field = [ ]
// 结果格式 2020-01
this.field.push(temp)
// this.fieldValue = [ ]
// 结果格式 2020-01-28
this.fieldValue.push(temp + '-' + '28')
++m1
count --
++i
}else {
m1 -= 12
y1++
}
}
}
},