ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

In DatePicker week mode, if the valueFormat parameter is specified, the displayed value is abnormal

Open atom-git opened this issue 3 years ago • 3 comments
trafficstars

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.2.6

Environment

ant design vue 3.2.10

Reproduction link

Edit on CodeSandbox

Steps to reproduce

尝试过引入 import advancedFormat from 'dayjs/plugin/advancedFormat' import weekOfYear from 'dayjs/plugin/weekOfYear' 等方式均不能成功

What is expected?

使用valueFormat能够正常显示值

What is actually happening?

change时获取到的值正常,显示的值为当年第一周

atom-git avatar Jul 28 '22 08:07 atom-git

dayjs不支持dayjs('2022-33', 'YYYY-ww')

gp0119 avatar Aug 06 '22 03:08 gp0119

https://github.com/vueComponent/ant-design-vue/blob/7473233bc95b587232afed64c3d5ef8269fb8023/components/date-picker/generatePicker/generateSinglePicker.tsx#L80 https://github.com/vueComponent/ant-design-vue/blob/7473233bc95b587232afed64c3d5ef8269fb8023/components/date-picker/generatePicker/generateSinglePicker.tsx#L81

maybeToString 在有valueFormat的情况下会将value转为string,而value的类型又是Dayjs,导致更新错误。这边如果采用的是emit('update:value', data)就没问题。 现阶段的话可以不使用双向绑定,在onchange事件中取format过的值。 感觉使用valueFormat的话再使用v-modal是不是有点矛盾。 @atom-git @tangjinzhou @gp0119

RookieChen4 avatar Aug 10 '22 14:08 RookieChen4

dayjs不支持dayjs('2022-33', 'YYYY-ww')

通过引入插件是支持的 import advancedFormat from 'dayjs/plugin/advancedFormat' import weekOfYear from 'dayjs/plugin/weekOfYear'

atom-git avatar Sep 15 '22 23:09 atom-git