Skip to content

🐛[BUG]EditableProTable中的日期选择框报错 #6785

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

Closed
fybchristasker opened this issue Mar 15, 2023 · 6 comments
Closed

🐛[BUG]EditableProTable中的日期选择框报错 #6785

fybchristasker opened this issue Mar 15, 2023 · 6 comments
Labels

Comments

@fybchristasker
Copy link

fybchristasker commented Mar 15, 2023

提问前先看看:

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

🐛 bug 描述

clone.weekday() is not a function

📷 复现步骤

我的项目是dayjs1.11.7,会报错;
安装dayjs1.11.4后恢复正常。

🏞 期望结果

💻 复现代码

© 版本信息

  • ProComponents 版本: [e.g. 4.0.0]
  • umi 版本
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

@github-actions
Copy link

github-actions bot commented Mar 15, 2023

以下的 Issues 可能会帮助到你 / The following issues may help you

@chenshuai2144
Copy link
Contributor

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

针对你提供的问题描述,是一个"clone.weekday() is not a function" 的报错信息。这可能是因为你在使用 EditableProTable 组件时使用了 dayjs 1.11.7 版本,导致出现兼容性问题。安装 dayjs 1.11.4 后问题得到了解决。

那么,为了避免这个问题的出现,建议在使用 EditableProTable 组件时,使用兼容性更好的 dayjs 版本,比如 dayjs 1.10.x 版本或者更高版本(建议使用最新版本)。

同时,在处理日期时,建议使用 dayjs 所提供的方法,如 dayjs().format() 或 dayjs().diff() 等,具体使用方法可以参考 dayjs 的文档:https://day.js.org/docs/en/。

另外,如果你遇到了其他的问题,也建议提供更详细的问题描述和可复现的代码,这样才能更快地帮助你解决问题。

@chenshuai2144
Copy link
Contributor

dayjs 做了api的break升级了吗? 看起来好像没有欸

@xiaodel
Copy link

xiaodel commented Mar 30, 2023

我怎么感觉我这个默认调用的是moment.js

@chenshuai2144
Copy link
Contributor

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

对于你遇到的问题,也有可能是因为你默认调用的是 moment.js,而不是使用 dayjs,所以你需要在你的代码中对日期进行正确的处理。

对于日期处理,moment.js 和 dayjs 有一些区别。具体来说,dayjs 的 API 类似于 moment.js,但是比 moment.js 更轻量级和更快,支持链式调用,可以轻松地转换日期格式,并且具有各种获取日期差异、格式化、解析、有效性检查等功能。

如果你想切换到 dayjs,请先卸载 moment.js,然后使用 npm 安装 dayjs:

npm uninstall moment
npm install dayjs

然后,在你的项目代码中使用:

import dayjs from 'dayjs'

来代替原来的 moment.js,这样就可以使用 dayjs 的所有功能了。

更多关于如何使用 dayjs 的例子和方法,请参考 dayjs 的官方文档:https://day.js.org/docs/en/。同时,还有 dayjs 文档中提供的一些 dayjs 的工具和插件,可以根据需要选择不同的工具和插件来进行开发。

@chenshuai2144
Copy link
Contributor

chenshuai2144 commented Jul 15, 2023

两个无缝转化的,注意下依赖版本即可

不要两份dayjs 和两份 moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants