ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.23k stars 1.35k forks source link

🧐[问题] antd 与 pro-component 引入的Dayjs 版本不同 #7397

Closed killer-wu closed 1 year ago

killer-wu commented 1 year ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🧐 问题描述

antd 引入了dayjs1.11.7的版本,pro-component引入了dayjs1.11.9的版本 这样导致在使用日期选择器的时候会出现版本不兼容的问题

再次点击日期选择器的时候会报错

💻 示例代码

{ title: '订单生成时间', dataIndex: 'create_time', align: 'center', valueType: 'dateTimeRange', fieldProps: { locale: 'zh-en' }, search: { transform: (value) => { const [start, end] = value

                // 临时解决
                return {
                    create_time_start: moment(start.$d).unix(),
                    create_time_end: moment(end.$d).unix()
                }
            }
        },
        render: (_, record) => {
            return record?.create_time ? moment.unix(record.create_time).format('YYYY-MM-DD HH:mm:ss') : '-'
        }
    },

🚑 其他信息

"antd": "^5.7.1", "@ant-design/pro-components": "^2.6.6",

image

github-actions[bot] commented 1 year ago

当前 Issue 未检测到标题,请规范填写,谢谢!

The title of the current issue is not detected, please fill in according to the specifications, thank you!

killer-wu commented 1 year ago

看之前提过此问题,给项目安装一个最新版dayjs可以解决,安装之后报错是没有了,但是无法汉化了。 image

import moment from "moment/moment"; import dayjs from "dayjs"; import 'dayjs/locale/zh-cn'; import 'moment/locale/zh-cn'; moment.locale('zh-cn'); dayjs.locale('zh-cn');

lovewinders commented 1 year ago

我当初也碰到这个问题,pnpm管理本地项目dayjs版本和pro-components中依赖版本不一致,导致线上2套dayjs实例问题引起的,后来我把本地dayjs修改为同pro-components一致的就可以了

killer-wu commented 1 year ago

我当初也碰到这个问题,pnpm管理本地项目dayjs版本和pro-components中依赖版本不一致,导致线上2套dayjs实例问题引起的,后来我把本地dayjs修改为同pro-components一致的就可以了

是的这样确实能解决兼容问题,就是汉化有问题了

WuJiY commented 1 year ago

+1