import 'moment/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
<DatePicker locale={locale} />;
μμ λ₯Ό κ·Έλλ‘ λ°λΌνλλ°, μλ λ¬Έμ κ° λ°μνλ€. π
λ³κ±° μλμ§λ§, λκ°μ λ¬Έμ κ° λ°μν κ°λ°μμκ² μ½μ§μ μκ°μ μ€λ €λ³΄κ³ μ μμ±νλ€..
Server Error
SyntaxError: Unexpected token 'export'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///node_modules/rc-picker/es/locale/en_US.js (1)
file:///node_modules/rc-pagination/es/locale/en_US.js (1)
file:///node_modules/rc-notification/es/locale/en_US.js (1)
Next.js
λ Default
λ‘ src
ν΄λμ μλ ES6 μ½λλ§ νΈλμ€ νμΌ νλλ‘ babel-loader
κ° κ΅¬μ±λμ΄μλ€.node_modules
μμ κ°μ Έμ¨ λͺ¨λ ES6 μ½λλ λ³ν μμ΄ μ΅μ’
λ²λ€λ‘ μ§μ μ΄λν΄μ λ°μν λ¬Έμ λ€.next.config.js
νμΌ μμμ webpack
μ€μ μ μμ νμ.// next.config.js
const withTM = require('next-transpile-modules')([
'antd',
'rc-picker',
'rc-pagination',
'rc-notification',
])
Server Error
SyntaxError: Cannot use import statement outside a module
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
/node_modules/rc-util/es/omit.js (1)
/node_modules/ (ant-design/icons/es/components/Context.js (1)
ν΄λΉ μλ¬λ λμΌνκ² μ²λ¦¬νλ©΄ λλ€κ³ νλ€.
νκΈννλλ°, μ°κ΄λ ν¨ν€μ§λ₯Ό λ€ νΈλμ€ νμΌ ν΄μ€μΌ νλ κ² κ°λ€.
νλνλ λ£μ΄μ£Όλ€ 보λ μλκ° μ΅μ’
μ½λμ΄λ€.
// next.config.js
const withTM = require('next-transpile-modules')([
'antd',
'rc-picker',
'rc-util',
'@ant-design/icons',
'rc-pagination',
'rc-notification',
])
π¨ μ΄μ λλμ΄ μλ¬κ° λ°μνμ§ μκ³ νκΈν λμλλ°, moment
λ λ²λ€ μ¬μ΄μ¦λ₯Ό λ§μ΄ μ‘μλ¨Ήλλ€. dayjs
λ‘ λ°κΏλ³΄μ.
// components/common/DatePicker.tsx
import { Dayjs } from 'dayjs';
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs';
import generatePicker from 'antd/es/date-picker/generatePicker';
const DatePicker = generatePicker<Dayjs>(dayjsGenerateConfig);
export default DatePicker;
μ΄λ κ² μ¬μ©νλ©΄ dayjs
λ₯Ό μ¬μ©νλ€.
import 'dayjs/locale/ko'
import
λ₯Ό μΆκ°ν΄μ νκΈνλ₯Ό λ§λ¬΄λ¦¬νλ€.
λλ΅ μ 리λ μ½λλ μλμ κ°λ€.
μ»΄ν¬λνΈλ‘ λ§λ€μ΄μ μ¬μ©νλ©΄ λ κ² κ°λ€.
import 'dayjs/locale/ko'
import { Dayjs } from 'dayjs'
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs'
import generatePicker from 'antd/es/date-picker/generatePicker'
import locale from 'antd/es/date-picker/locale/ko_KR'
const DatePicker = generatePicker<Dayjs>(dayjsGenerateConfig)
interface AntDatePickerProps {
// ...
}
export const AntDatePicker = ({ }: AntDatePickerProps) => {
return <DatePicker locale={locale} />
}
μ΄μ transpilePackagesλ₯Ό μ¨μΌ ν©λλ€