Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] 选择框在没有手势触摸前,js直接设置值会没有滚动动画。picker-column的默认值问题 #5962

Open
Hmyou opened this issue Jan 23, 2025 · 0 comments

Comments

@Hmyou
Copy link

Hmyou commented Jan 23, 2025

重现链接

<!--pages/demo/demo.wxml-->
<view style="padding-top:150px;">
  <van-datetime-picker
    type="date"
    value="{{ currentDate }}"
    bind:input="onInput"
    min-date="{{ minDate }}"
    formatter="{{ formatter }}"
  />
</view>
<view style="padding-top:50px;">
  <van-button bindtap="clickChoose">往后选6个月</van-button>
</view>
Page({
  data: {
    currentDate: new Date().getTime(),
    minDate: new Date().getTime(),
    formatter(type, value) {
      if (type === 'year') {
        return `${value}年`;
      }
      if (type === 'month') {
        return `${value}月`;
      }
      return value;
    },
  },

  onInput(event) {
    this.setData({
      currentDate: event.detail,
    });
  },

  clickChoose() {
    const cur = this.data.currentDate
    this.setData({
      currentDate: cur + 1000 * 60 * 60 * 24 * 30 * 6
    })
  }
});

Vant Weapp 版本

1.11.7

描述一下你遇到的问题。

直接点击按钮,通过this.setData设置时间选择器的值,会没有滚动动画;
当手势触摸滑动选择框后,再通过点击按钮js设置值,是会有预期的滚动动画。
查看@vant/weapp/lib/picker-column/index.js 发现DEFAULT_DURATION的值没有被设置在this.data.duration的初始值上。

重现步骤

重现链接中的代码demo,打开后直接点击按钮设置时间没有动画,手势触摸滑动时间选择器后再点按钮设置时间即可有动画

设备/浏览器

No response

@Hmyou Hmyou changed the title [Bug Report] 选择框在没有手势触摸前,js直接设置值会没有滚动动画 [Bug Report] 选择框在没有手势触摸前,js直接设置值会没有滚动动画。picker-column的默认值问题 Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant