引入 antd 就报 Critical dependency: require fun... 的错误

在creat-react-app 中引入 antd 如下

import {Button} from 'antd'

无论什么组件,只要是antd 控制台就会报错如下

./node_modules/ua-parser-js/src/ua-parser.js
1010:12-19 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

浏览器就是这样显示的

×
Error: Cannot find module "."
▶ 50 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
阅读 3.4k
1 个回答

你这样引用应该要配置babel-plugin-import(按需加载组件)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题