Skip to content
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

配置了antd-dayjs-webpack-plugin后 ,时间选择器的国际化没生效 #69

Open
AliyaLiu opened this issue Dec 29, 2021 · 2 comments

Comments

@AliyaLiu
Copy link

按照官方配置,利用webpack-chain添加plugin,配置如下

const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
module.exports = ({ onGetWebpackConfig }) => {
   onGetWebpackConfig((config) => {
       config.plugin('AntdDayjsWebpackPlugin').use(AntdDayjsWebpackPlugin);
  })
}

app.tsx中添加

import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';

dayjs.locale('zh-cn');

<ConfigProvider locale={zhCN}>{children}</ConfigProvider>;

代码中引入时间选择器

import { DatePicker } from 'antd';

export default function Home() {

  return (
    <div>
      <DatePicker />
    </div>
  );
}

时间选择器月份没有格式化掉,请问是什么问题~
image

 "antd": "4.17.3",
 "dayjs": "1.10.7",
 "antd-dayjs-webpack-plugin": "1.0.6",
@yangxiaoguai132
Copy link

我也遇到了相同的问题,请问有解决方式么

@WillieChan2015
Copy link

笑死,引用回moment的国际化之后,就正常了

import moment from 'moment';
import 'moment/locale/zh-cn';

moment.locale('zh-cn');

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

No branches or pull requests

3 participants