问题需求:el-date-picker的默认格式是[‘2022-08’, ‘2023-01’],业务需求是首次打开页面,默认值为当前6个月,并以[‘2022-08’, ‘2022-09’, ‘2022-10’, ‘2022-11’, ‘2022-12’]的格式补全区间传递给后端。方法如下:
<el-date-picker
v-model="monthsList"
type="monthrange"
clearable
@change="chooseMonths"
value-format="yyyy-MM"
start-placeholder="起始月份"
range-separator="至"
end-placeholder="结束月份"
>
</el-date-picker>
// 补全默认的6个月
dealMonth() {
let arr = []
let thisMonth = this.$moment(new Date()).format('yyyy-MM')
// let thisMonth = '2023-01'
let str1 = thisMonth.substring(0, 4)
let num1 = thisMonth.substring(5, 7)
arr.push(thisMonth)
if (Number(nu