爆款云服务器低至4折,1核1G¥366/

根据文档 https://ant.design/docs/react/i18n-cn 使用 ConfigProvider 全局配置国际化文案时,出现如下错误

import Pagination from "rc-pagination/es/locale/zh_CN";
       ^^^^^^^^^^

SyntaxError: Unexpected identifie

pages/_app.js 代码如下:

import React from 'react'
import App from 'next/app'
import { ConfigProvider } from 'antd'
import zhCN from 'antd/es/locale/zh_CN'

import '../less/global.less'

class MyApp extends App {
  render() {
    const { Component, pageProps} = this.props

    return (
      <ConfigProvider locale={zhCN}>
        <Component {...pageProps} />
      </ConfigProvider> 
    )
  }
}

export default MyApp

解决方法:
import zhCN from 'antd/es/locale/zh_CN' 改成 import zhCN from 'antd/lib/locale/zh_CN'

参考链接:https://github.com/ant-design/ant-design/issues/18336

标签: none