🐛(component): datePicker dayJS解析时间错误

This commit is contained in:
0o张不歪o0 2022-07-14 10:49:19 +08:00
parent 2a4dc6532d
commit d697f0b100

View File

@ -330,8 +330,7 @@ const els = [
const currentYear = ref(getYear()); const currentYear = ref(getYear());
const currentMonth = ref(getMonth()); const currentMonth = ref(getMonth());
const currentDay = ref<number>(); const currentDay = ref<number>(props.modelValue? new Date(props.modelValue).getTime(): -1);
const yearList = ref<number[]>(getYears()); const yearList = ref<number[]>(getYears());
const dateList = ref<any[]>([]); const dateList = ref<any[]>([]);
const showPane = ref("date"); const showPane = ref("date");
@ -345,18 +344,19 @@ watch(
); );
onMounted(() => { onMounted(() => {
currentDay.value = props.modelValue
? new Date(props.modelValue).getTime()
: -1;
if (currentDay.value == -1) { if (currentDay.value == -1) {
setTimeout(() => { setTimeout(() => {
now(); now();
clear(); clear();
}, 0); }, 0);
} }
hms.value.hh = dayjs(props.modelValue).hour(); let modelValue=props.modelValue;
hms.value.mm = dayjs(props.modelValue).minute(); if(modelValue.length===8){ //dayjs
hms.value.ss = dayjs(props.modelValue).second(); modelValue='1970-01-01 '+modelValue;
}
hms.value.hh = dayjs(modelValue).hour();
hms.value.mm = dayjs(modelValue).minute();
hms.value.ss = dayjs(modelValue).second();
}); });
// //