@@ -60,8 +60,8 @@ export default {
6060 </script >
6161
6262<script lang="ts" setup>
63- import { computed , nextTick , onMounted , ref , watch } from ' vue'
64- import { debounce , isArray , isEqual , isNumber } from ' ../../common/util'
63+ import { computed , onMounted , ref , watch } from ' vue'
64+ import { debounce , isArray , isEqual , isNumber , requestAnimationFrame } from ' ../../common/util'
6565import { compareMonth , formatMonthTitle , getMonthEndDay , getMonths , getTimeData , getWeekLabel } from ' ../utils'
6666import Month from ' ../month/month.vue'
6767import { monthPanelProps , type MonthInfo , type MonthPanelTimeType , type MonthPanelExpose } from ' ./types'
@@ -152,7 +152,7 @@ const handleChange = debounce((value) => {
152152 * 使当前日期或者选中日期滚动到可视区域
153153 */
154154function scrollIntoView() {
155- setTimeout (() => {
155+ requestAnimationFrame (() => {
156156 let activeDate: number | null = 0
157157 if (isArray (props .value )) {
158158 activeDate = props .value ! [0 ]
@@ -174,20 +174,17 @@ function scrollIntoView() {
174174 top += monthsInfo [index ] ? Number (monthsInfo [index ].height ) : 0
175175 }
176176 scrollTop .value = 0
177- nextTick (() => {
177+ requestAnimationFrame (() => {
178178 scrollTop .value = top
179179 })
180- }, 50 )
180+ })
181181}
182182/**
183183 * 获取时间 picker 的数据
184184 * @param {timestamp|array} value 当前时间
185185 * @param {string} type 类型,是开始还是结束
186186 */
187187function getTime(value : number | (number | null )[], type ? : string ) {
188- if (! props .value ) {
189- return []
190- }
191188 if (props .type === ' datetime' ) {
192189 return getTimeData ({
193190 date: value as number ,
@@ -243,7 +240,6 @@ function setTime(value: number | (number | null)[], type?: MonthPanelTimeType) {
243240 if (isArray (value ) && value [0 ] && value [1 ] && type === ' start' && timeType .value === ' start' ) {
244241 type = ' end'
245242 }
246-
247243 timeData .value = getTime (value , type ) || []
248244 timeValue .value = getTimeValue (value , type || ' ' )
249245 timeType .value = type || ' '
0 commit comments