diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 33e4a5ba..200ca38e 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -330,8 +330,7 @@ const els = [ const currentYear = ref(getYear()); const currentMonth = ref(getMonth()); -const currentDay = ref(); - +const currentDay = ref(props.modelValue? new Date(props.modelValue).getTime(): -1); const yearList = ref(getYears()); const dateList = ref([]); const showPane = ref("date"); @@ -345,18 +344,19 @@ watch( ); onMounted(() => { - currentDay.value = props.modelValue - ? new Date(props.modelValue).getTime() - : -1; if (currentDay.value == -1) { setTimeout(() => { now(); clear(); }, 0); } - hms.value.hh = dayjs(props.modelValue).hour(); - hms.value.mm = dayjs(props.modelValue).minute(); - hms.value.ss = dayjs(props.modelValue).second(); + let modelValue=props.modelValue; + if(modelValue.length===8){ //dayjs 解析时间容错 + modelValue='1970-01-01 '+modelValue; + } + hms.value.hh = dayjs(modelValue).hour(); + hms.value.mm = dayjs(modelValue).minute(); + hms.value.ss = dayjs(modelValue).second(); }); // 计算结果日期