使用footer插槽进行清除功能添加

<template slot="footer">
<div class="btns">
<van-button @click="clearTimeAll" type="danger" class="cancel-btn"
>清除时间</van-button
>
<van-button
@click="onConfirmAll"
type="primary"
class="order-btn-order"
:disabled="isCanConfirm"
>确认</van-button
>
</div>
清除功能添加事件对默认时间重置及设置初始数据
clearTimeAll () {
this.startTime = '开始时间'
this.endTime = '结束时间'
this.earlyDate = undefined
this.lateDate = undefined
this.selectDate = []
this.$refs.alltime.defaultDate = null
this.$refs.alltime.reset()
},
确认功能调整
<van-calendar
v-model="showCalendar"
ref="alltime"
type="range"
allow-same-day
:min-date="minDate"
:max-date="maxDate"
color="#1989fa"
:default-date="null"
@confirm="onConfirm"
@select="select"
:show-confirm="false"
>
// 日期取值
onConfirm (val) {
console.log('val', val);
let [startTime, endTime] = val
this.startTime = moment(startTime).format('YYYY-MM-DD')
this.endTime = moment(endTime).format('YYYY-MM-DD')
},
// 确认
onConfirmAll () {
this.showCalendar = false;
this.$emit('confirm', this.unit, this.projectId, this.objectId, params)
},
取消默认时间,并滚动到当前时间位置
watch: {
showCalendar (val) {
if (val) {
this.$refs.alltime.scrollToDate(new Date())
}
},