Skip to content

Commit 3746ba3

Browse files
author
xuqingkai
committed
fix: 🐛 修复Calendar的type为datetime且无默认值时无法在首次选择日期后选择时间的问题
Closes: #214
1 parent 61e7cdf commit 3746ba3

File tree

1 file changed

+5
-9
lines changed
  • src/uni_modules/wot-design-uni/components/wd-calendar-view/monthPanel

1 file changed

+5
-9
lines changed

src/uni_modules/wot-design-uni/components/wd-calendar-view/monthPanel/month-panel.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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'
6565
import { compareMonth, formatMonthTitle, getMonthEndDay, getMonths, getTimeData, getWeekLabel } from '../utils'
6666
import Month from '../month/month.vue'
6767
import { monthPanelProps, type MonthInfo, type MonthPanelTimeType, type MonthPanelExpose } from './types'
@@ -152,7 +152,7 @@ const handleChange = debounce((value) => {
152152
* 使当前日期或者选中日期滚动到可视区域
153153
*/
154154
function 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
*/
187187
function 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

Comments
 (0)