Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] umi3 项目 antd 组件报红 #10794

Closed
dparticle opened this issue Jun 16, 2023 · 3 comments
Closed

🐛 [BUG] umi3 项目 antd 组件报红 #10794

dparticle opened this issue Jun 16, 2023 · 3 comments

Comments

@dparticle
Copy link

🐛 bug 描述

pro cli 创建 umi3 项目,安装依赖后,所有 antd 组件在 vscode 中报错如下:

image

尝试将 React 升级到 18,不会报错。

🏞 期望结果 | Expected results

消灭红色

© 版本信息

  • Ant Design Pro 版本: v5
  • umi 版本: ^3.5.0
  • 开发环境: macOS, VSCode(1.79.1)
@github-actions
Copy link

以下的 Issues 可能会帮助到你 / The following issues may help you

@hhy123540
Copy link

你好 请问这个vscode标红 您解决了吗

@chenshuai2144
Copy link
Collaborator

值得注意是的百分之二十的问题都可以用重装依赖来解决,所以你可以尝试一下:
删除 'node_modules' 文件夹 -> 删除 'package-lock.json'或 'pnpm-lock.yaml' 文件 -> 运行 'pnpm install' 或 'npm install' 命令

根据问题描述,这个 bug 是在 umi3 项目中使用 antd 组件时出现红色报错。可以尝试以下解决方案:

  1. 确认依赖版本:检查 umi 和 antd 的版本是否与问题描述中的版本一致。如果不一致,可以尝试将它们升级到最新版本。

  2. 检查配置:确保在 umi3 项目的配置文件中正确引入了 antd 组件库,并且按照官方文档配置了 babel 插件和样式引入。

  3. 检查编译环境:确认编译环境是否正确配置了 babel 插件和样式引入。如果使用的是 VSCode,可以确保安装了相关的插件,比如 "vscode-babel-coloring" 或 "vscode-styled-components"。

  4. 检查引入方式:确认 antd 组件的引入方式是否正确。可以尝试使用按需引入的方式,仅引入需要使用的组件,而不是全部引入。

  5. 检查 React 版本:根据问题描述,升级 React 到 18 版本后报错消失。可以考虑将 React 版本升级到最新的稳定版本。

  6. 检查其他依赖冲突:如果以上方法都无效,可以尝试升级其他依赖项,或者检查是否有其他依赖项与 antd 或 umi3 发生冲突。

如果以上方法都没有解决问题,建议在 antd 的 GitHub 仓库中提一个 issue,详细描述你遇到的问题,并提供重现步骤和环境信息,以便开发者能更快地解决问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants