html
<el-date-picker
v-model="value1"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
script
data:[
startEndTime: [moment().valueOf(), moment().valueOf()],
],
methods:{
buling(num) {
for (var len = (num + "").length; len < 2; len = num.length) {
num = "0" + num;
}
return num;
},
Date() {
var date = new Date(); //创建日期对象
var year = date.getFullYear();
var month = date.getMonth() + 1;
var dates = date.getDate();
let str = year + "-" + this.buling(month) + "-" + this.buling(dates - 1);
let str2 = year + "-" + this.buling(month) + "-" + this.buling(dates + 1);
this.value1.push(str);
this.value1.push(str2);
},
}
注意:需要引入moment
|