<script setup lang="ts">
import { ref, reactive } from 'vue'
const dateRangePackYearTime = ref([])
const datePicker = reactive({
startData: null as number | null,
});
// 选择日期开始时间
const dateRangeClear = (time: any) => {
let hasSelectDate = time !== null && time.length > 0;
datePicker.startData = hasSelectDate
? Math.floor(time[0].getTime() / 1000)
: null;
};
//重置日期开始时间
const timeChange = (time: any) => {
datePicker.startData = null
};
// 禁用时间选项
const disabledDate = (time: any) => {
if (datePicker.startData !== null) {
const startDate = new Date(datePicker.startData * 1000);
let beforeDate: Date;
let afterDate: Date;
// 年-显示年, 最多5年内
beforeDate = new Date(startDate);
afterDate = new Date(startDate);
beforeDate.setFullYear(startDate.getFullYear() - 5);
afterDate.setFullYear(startDate.getFullYear() + 5);
return time.getTime() < beforeDate.getTime() || time.getTime() > afterDate.getTime();
}
return false;
};
</script>
<template>
<el-date-picker :clearable="false" @calendar-change="dateRangeClear" @change="timeChange"
:disabled-date="disabledDate" v-model="dateRangePackYearTime" format="YYYY"
value-format="YYYY" type="yearrange" range-separator="-"
start-placeholder="开始日期" end-placeholder="结束日期" />
</template>
Bug Type:
ComponentEnvironment
3.2.452.8.0UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36ViteReproduction
Related Component
el-date-pickerReproduction Link
Element Plus Playground
Steps to reproduce
What is Expected?
悬浮样式在鼠标指示的时间上
What is actually happening?
悬浮样式不在鼠标指示的时间上

如图,鼠标在2025上,但是悬浮样式在2021上
选择开始时间后,鼠标指示能选择的最后结束时间,悬浮样式不生效
其它时间正常
Additional comments
(empty)