<!-- 统计时间 -->
<van-cell title="统计时间:" v-model="date" @click="dateShow = true" />
<van-calendar allow-same-day v-model="dateShow" type="range" @confirm="dateOnConfirm" />
// 点击日期确定
dateOnConfirm(date) {
console.log("点击日期确定", date);
let begin = moment(date[0]).format("YYYY-MM-DD");
let finish = moment(date[1]).format("YYYY-MM-DD");
this.form.beginDate = moment(begin).unix();
this.form.endDate = moment(finish).unix();
const [start, end] = date;
this.dateShow = false;
this.date = `${this.formatDate(start)} - ${this.formatDate(end)}`;
},
moment(2022-12-14).unix()转化为时间戳-----这边用unix()转化得出的时间戳是秒,正常还需要*1000转化为毫秒,正常我们的时间戳是以毫秒为单位
网友评论