在react项目导入antd.css报错
在项目导入了antd,在引用他样式的时候,项目报错,如果用import 导入antd.css,页面能正常出现,但终端这里一直报错,大概就是这个:
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map: ‘webpack://antd/./components/time-picker/style/index.less’ URL is not supported
我也不知道为啥,但我找到的解决方案哈哈哈哈哈:
官网中是这样写的:
解决方案:
不要直接在js里面引入antd/dist/antd.css
而是在css中@import '~antd/dist/antd.css';再在项目入口 app.js中引入自己的css即可
app.css
@import '~antd/dist/antd.css';
app.js
import './App.css'
这样子就不会报错了哦~