-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] ProTable.ProColumns.FieldProps.Format is not localizable. #7348
Comments
感谢您提交的问题。 根据您提供的信息,您遇到的问题是关于 ProTable 组件 ProColumns 的 FieldProps 的 format 属性无法本地化的问题。根据您的代码和截图,您使用的 ProTable 版本是 2.x。 要解决此问题,您需要进行以下步骤:
import 'moment/locale/zh-cn';
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
通过这些步骤,您应该能够解决 ProTable 组件 ProColumns 的 FieldProps 的 format 属性无法本地化的问题。 希望对您有所帮助!如果您还有其他问题,请随时提问。 |
this is not the answer to the question. |
I apologize for the misunderstanding. To address the issue you mentioned, the ProTable.ProColumns.FieldProps.Format not being localizable, you can use the moment.js library to format the date in a localized manner. In your code snippet, you're already using the moment.js library. To make the date format localized, you can add the following code: import moment from 'moment';
import 'moment/locale/zh-cn'; // Import the locale you want to use, e.g., Chinese (Simplified)
export const useApplicationTableColumns = (): ProColumns<DTOS.ApplicationDto>[] => {
return [
{
title: 'Creation Date',
dataIndex: 'creationDate',
valueType: 'dateTime',
fieldProps: {
format: moment.localeData().longDateFormat('L') // Use the localized format
}
}
];
}; By importing the specific locale you want to use and setting the format to Make sure you have the necessary dependencies installed: "dependencies": {
"moment": "^2.29.4"
} Also, ensure that you have the correct version of the "@ant-design/pro-components" package installed. Please give this solution a try, and let me know if you have any further questions or issues. |
But this is a bug, You can't fix this issue like this;
|
I apologize for the misunderstanding. If the issue you're facing is indeed a bug with the ProTable component's FieldProps format not being localizable, I'm sorry for the confusion. As a GitHub issue assistant, I can't directly fix bugs in the ProTable component. However, I can provide some suggestions on how to approach and potentially resolve the issue:
Remember to follow the issue template and guidelines provided by the project maintainers when opening a new issue. I'm sorry for any inconvenience caused by the bug. I recommend following the steps above to address the issue properly. |
我们用的是dayjs,你试试dayjs |
我也使用 dayjs,但 ProColumns 'format' 属性无法识别 localizedFormat。 |
是不是 dayjs 的插件没装,你搞个重现呗。 |
The dayjs plugin is already installed in umijs, is there any point in reinstalling it? I added the required plugins in the umijs config file.
Do I need to install dayjs externally to use the format property of ProColumns' dateTime valueType property? Did I get right? I'm currently solving this situation as follows, but I would prefer to be able to use the "format" property.
|
已内置支持,可以升级到 2.7.15 以使用该特性。 |
console.log(record.creationDate);
--> "creationDate": "2023-07-03T12:54:28",
Screenshots.
config.ts
package.json
The text was updated successfully, but these errors were encountered: