uView2.0 icon indicating copy to clipboard operation
uView2.0 copied to clipboard

Calendar组件在小程序使用时,打开月份定位不准确

Open xieguapi opened this issue 1 year ago • 2 comments

版本

2.0.36

转载链接

www.uviewui.com

重现步骤

<template>
  <view>
    <u-button text="打开日历" @click="showCalendar = true" />
    <u-calendar
      mode="range"
      allowSameDay
      :monthNum="13"
      :minDate="minDate"
      :show="showCalendar"
      :defaultDate="date"
      @close="closeDatePicker"
      @confirm="confirmDatePicker"
    />
  </view>
</template>

<script>
export default {
  data() {
    return {
      showCalendar: false,
      date: []
    }
  },
  computed: {
    minDate() {
      const curDate = new Date()
      curDate.setFullYear(curDate.getFullYear() - 1)
      return uni.$u.timeFormat(curDate)
    }
  },
  methods: {
    closeDatePicker() {
      this.showCalendar = false
    },
    confirmDatePicker(date) {
      this.closeDatePicker()
      this.date = [date[0], date[date.length - 1]]
    }
  }
}
</script>

期望的结果是什么?

每次打开组件都能正确定位

实际的结果是什么?

当前日期为2023年4月,打开应该定位到2023年4月的位置,但实际效果为: 第一次打开时,定位到了2023年3月的位置 第二次打开时,定位正确 第三次打开时,只有标题显示2023年4月,但实际定位scrollTop为0的位置 之后打开时,标题为上一次打开滚动的位置,但实际定位为scrollTop为0的位置

以上步骤都是直接打开再关闭,未进行选择的情况下复现

xieguapi avatar Apr 11 '23 07:04 xieguapi