<div class="time mt30 bgc">
<span
:class="['cursor', { active: search.timeType === 0 }]"
@click="changeTimeType(0), init()"
>月</span
>
<span
:class="['cursor', { active: search.timeType === 1 }]"
@click="changeTimeType(1), init()"
>年</span
>
<span @click="show = !show">日历</span>
</div>
methods:{
// 月/年
changeTimeType(type) {
const date = new Date();
const year = date.getFullYear();
const month =
date.getMonth() + 1 < 10
? `0${date.getMonth() + 1}`
: date.getMonth() + 1;
const days = date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
if (type === 1) this.search.startTime = `${year}/01/01`;
else this.search.startTime = `${year}/${month}/01`;
this.search.endTime = `${year}/${month}/${days}`;
this.search.month = `${month}`;
this.search.year = `${year}`;
this.search.timeType = type;
},
}