antd 报错: Could not find "store" in the context of

Error: Could not find "store" in the context of "Connect(MyCert)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(MyCert) in connect options.

目录写错: model —> models

这个错误是因为你尝试从 `node_modules` 中引入全局 CSS 文件,而 Webpack 默认不允许这样做。你可以通过在 Webpack 配置文件中添加一些选项来解决这个问题。 在 `webpack.config.js` 中,添加以下代码: ```javascript module.exports = { // ... module: { rules: [ // ... { test: /\.less$/, use: [ // ... { loader: 'less-loader', options: { lessOptions: { javascriptEnabled: true, }, }, }, ], }, ], }, // ... }; ``` 这段代码将启用 JavaScript 解析 Less 文件,并将其转换为 CSS 文件。由于这是全局 CSS 文件,因此需要将 `less-loader` 改为 `style-loader` 和 `css-loader`。 如果你在使用 `create-react-app`,则可以通过在 `package.json` 中添加以下内容来解决这个问题: ```json { "name": "my-app", "version": "0.1.0", "private": true, "dependencies": { "antd": "^4.23.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "style": { "modules": true, "sourceMap": true, "importLoaders": 2, "localIdentName": "[name]__[local]___[hash:base64:5]" } } ``` 这将启用 CSS modules,并为它们生成局部类名。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值