<el-date-picker
v-model="value1"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期"
size="small"
@change="getTimeRange"
>
</el-date-picker>
JS方法
getTimeRange (value) {
let date = new Date(value); //value的格式为YYYY-MM-DD
let month = (date.getMonth() + 1).toString().padStart(2,'0'); //获取月份,如果月份小于10加个‘0’
let year = date.getFullYear();
this.startTime = year + '' + month + '01';
let day = new Date(year,month,0);
this.endTime = year + '' + month + '' + day.getDate();
},
网友评论