最近在写echarts图,需要新增需求,日期查询默认为当前日期,也可以自己手动选择某一时间段的日期,代码粘上了
<el-date-picker
v-model="month1"
style="width: 300px"
type="monthrange"
range-separator="至"
start-placeholder="开始月份"
end-placeholder="结束月份"
format="yyyy年-MM月"
value-format="yyyy-MM"
@change="search_Date"
>
</el-date-picker>
month1: [
`${
new Date().getMonth() < 1
? new Date().getFullYear() - 1
: new Date().getFullYear()
}-${new Date().getMonth() >= 9 || new Date().getMonth() < 1 ? "" : 0}${
new Date().getMonth() < 1 ? "12" : new Date().getMonth()
}`,
`${new Date().getFullYear()}-${new Date().getMonth() >= 9 ? "" : 0}${
new Date().getMonth() + 1
}`,
],
search_Date() {
this.leftCharts(this.month1[0], this.month1[1]);
},