diff --git a/package/component/src/component/datePicker/day.ts b/package/component/src/component/datePicker/day.ts index ac142fd6..5f64a621 100644 --- a/package/component/src/component/datePicker/day.ts +++ b/package/component/src/component/datePicker/day.ts @@ -12,24 +12,36 @@ const getYears = () => { /** * 获取当前日期 */ -const getDate = () => { - return new Date(); +const getDate = (val='') => { + if(val){ + return new Date(val); + }else{ + return new Date(); + } }; /** * 获取当前年份 */ -const getYear = () => { - return getDate().getFullYear(); +const getYear = (val='') => { + return getDate(val).getFullYear(); }; /** * 获取当前月份 */ -const getMonth = () => { - return getDate().getMonth(); +const getMonth = (val='') => { + return getDate(val).getMonth(); }; +const getDay=(val='')=>{ + if(val){ + return new Date(getDate(val).toDateString()).getTime(); + }else{ + return -1; + } +} + /** * 获取月份天数 * @@ -40,4 +52,4 @@ const getDayLength = (year: number, month: number): number => { return new Date(year, month + 1, 0).getDate(); }; -export { getDayLength, getYears, getDate, getMonth, getYear }; +export { getDayLength, getYears, getDate, getMonth, getYear,getDay }; diff --git a/package/component/src/component/datePicker/index.vue b/package/component/src/component/datePicker/index.vue index 200ca38e..de9db45f 100644 --- a/package/component/src/component/datePicker/index.vue +++ b/package/component/src/component/datePicker/index.vue @@ -1,12 +1,13 @@