reactjs 页面没有找到!无法解析“tdtd.css”

owfi6suc  于 2022-12-18  发布在  React
关注(0)|答案(1)|浏览(137)

我有这个问题。/src/index. js模块没有找到:无法解析“~antd/dist/antd.css”,我无法修复它。我尝试将@import“~antd/dist/antd.css”;.在css文件中.没有成功。
package.json:

{
  "name": "time-clock",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.6",
    "@testing-library/react": "^11.2.2",
    "@testing-library/user-event": "^12.5.0",
    "antd": "^4.9.2",
    "firebase": "^8.1.2",
    "polished": "^4.0.5",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.1",
    "styled-components": "^5.2.1",
    "web-vitals": "^0.2.4"
  },
    
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
oyjwcjzk

oyjwcjzk1#

@import '~antd/dist/antd.css';第一个月

仅适用于css或scss文件。

如果您使用-〉npx create-react-app yourAppName启动应用
不要将import 'antd/dist/antd.css';安装到您的index.js中,它将失败!!!

溶液

请勿使用GET STARTED DOCS
而是使用here中的Use in create-react-app
1.将@import '~antd/dist/antd.css';添加到App.css文件的顶部
1.然后,您应该能够在任何组件(如import { Button } from 'antd';)上使用它

相关问题