antd-dayjs-webpack-plugin
antd-dayjs-webpack-plugin copied to clipboard
配置了antd-dayjs-webpack-plugin后 ,时间选择器的国际化没生效
按照官方配置,利用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>
);
}
时间选择器月份没有格式化掉,请问是什么问题~
"antd": "4.17.3",
"dayjs": "1.10.7",
"antd-dayjs-webpack-plugin": "1.0.6",
我也遇到了相同的问题,请问有解决方式么
笑死,引用回moment的国际化之后,就正常了
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');