【问题标题】:Why are the icons not showing up on my Ant Design sider?为什么我的 Ant Design 侧边上没有显示图标?
【发布时间】:2020-08-30 11:32:05
【问题描述】:
<Sider collapsible collapsed={this.state.collapsed} onCollapse={this.onCollapse} breakpoint="md">
          <Menu
          theme="dark"
          mode="inline"
          defaultSelectedKeys={['10']}
          style={{ lineHeight: '64px' }}
          >                            
          <Menu.Item key="2" icon={<LoginOutlined />}><Link to="/login">Login</Link></Menu.Item>

这就是我的 Sider 代码的样子。但是,Sider 上仍然没有显示该图标。此代码在 CodeSandBox 上完美运行。使用最新版本的 Chrome。

即使是折叠的表单也不显示图标。

请帮忙。

编辑: 1. CodeSandbox 链接:https://codesandbox.io/s/sider-ant-design-demo-zkpcs?fontsize=14&hidenavigation=1&theme=dark 2. package.json:

{
  "name": "gui",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://exampple.com/",
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "antd": "^4.1.4",
    "axios": "^0.19.2",
    "babel-plugin-import": "^1.13.0",
    "customize-cra": "^0.9.1",
    "dayjs": "^1.8.23",
    "dotenv": "^8.2.0",
    "eslint": "^6.8.0",
    "eslint-plugin-flowtype": "^4.6.0",
    "gh-pages": "^2.2.0",
    "less": "^3.11.1",
    "less-loader": "^5.0.0",
    "react": "^16.13.1",
    "react-app-rewired": "^2.1.6",
    "react-dom": "^16.13.1",
    "react-ga": "^2.7.0",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.0",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "tsutil": "^6.1.1",
    "typescript": "^3.8.3"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "netlify deploy",
    "deployprod": "netlify deploy --prod",
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-scripts eject",
    "postinstall": "npm run build"
  },
  "engines": {
    "node": "13.7.0",
    "npm": "6.13.6"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

【问题讨论】:

  • 可以提供沙盒链接吗?
  • 嗨,我在编辑部分添加了链接。无论如何codesandbox.io/s/…
  • 你能显示你的 package.json 还是和codesandbox一样。如果您从以前的版本更新,请尝试删除 node_modules 和 package-lock.json。然后运行 ​​npm install @KshitijSinha
  • 您好,感谢您的回复。我在上面添加了package.json。

标签: reactjs antd ant-design-pro


【解决方案1】:

我所要做的就是从“antd”版本 4.0.0 更新到最新版本 4.6.3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-03
    • 1970-01-01
    • 2016-04-11
    • 1970-01-01
    • 2013-12-17
    • 1970-01-01
    • 2021-03-31
    • 2021-02-08
    相关资源
    最近更新 更多