antd-dayjs-webpack-plugin icon indicating copy to clipboard operation
antd-dayjs-webpack-plugin copied to clipboard

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

Open AliyaLiu opened this issue 3 years ago • 2 comments

按照官方配置,利用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",

AliyaLiu avatar Dec 29 '21 11:12 AliyaLiu

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

yangxiaoguai132 avatar Oct 13 '22 10:10 yangxiaoguai132

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

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

moment.locale('zh-cn');

WillieChan2015 avatar Apr 06 '23 07:04 WillieChan2015