element 默认当前月的第一天和最后一天
<el-form-item>
<el-date-picker
v-model="dateTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
data:[]
created(){
this.getTimeMonth();
}
methods: {
getTimeMonth(){
let myDate = new Date();
let month = myDate.getMonth() + 1;
month = month < 10 ? "0" + month : month; //格式化月份,补0
let statDateStart = myDate.getFullYear().toString()+"-" + month+"-" + "01"; //月初
let dayEnd = new Date(myDate.getFullYear(), month, 0).getDate(); //获取当月一共有多少天
let statDateEnd = myDate.getFullYear().toString()+"-" + month+"-" + dayEnd; //月末
this.dateTime.push(statDateStart, statDateEnd);
this.dateTime[0] =statDateStart;
this.dateTime[1] = statDateEnd;
},
}