vantui icon indicating copy to clipboard operation
vantui copied to clipboard

DatetimePicker 组件bug反馈

Open yujingwyh opened this issue 3 years ago • 0 comments

  1. 时间组件传了value,显示时无法回显

下面这个16毫秒时间太短,导致更新的时候对应的options还是为空数组,所以对应的值无法设置成功 不建议通过setTimeout的机制

//src/datetime-picker/index.tsx
//updateColumnValue方法里
return new Promise((resolve) => {
        setTimeout(() => {
          picker.setValues(values)
          resolve(value)
        }, 16)
      })
  1. 时间组件选择时间后又会自动恢复的之前的时间

这里setCurrentIndex是异步的,设置后currentIndex并不会立马更新 导致后面的onChange触发后,获取值时并没有获取到最新的值

//src/picker-column/index.tsx
//setIndex方法里

if (index !== currentIndex) {
        setCurrentIndex(index)
        setOffset(offset)
        if (onChange && userAction) onChange(curColIndex)
        return
}

环境 我这边是微信小程序环境,框架taro+preact

"preact": "10.6.6", Taro CLI 3.4.2 environment info: System: OS: macOS 12.2.1 Shell: 5.8 - /bin/zsh Binaries: Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm npmPackages: @tarojs/components: 3.4.1 => 3.4.1 @tarojs/mini-runner: 3.4.1 => 3.4.1 @tarojs/runtime: 3.4.1 => 3.4.1 @tarojs/taro: 3.4.1 => 3.4.1 @tarojs/webpack-runner: 3.4.1 => 3.4.1 babel-preset-taro: 3.4.1 => 3.4.1 eslint-config-taro: 3.4.1 => 3.4.1

yujingwyh avatar Mar 10 '22 08:03 yujingwyh