MUI自动导入建议在VS Code中不起作用,Next.js 13项目中。

huangapple go评论79阅读模式
英文:

MUI auto import suggestions not working in VS Code, Next.js 13 project

问题

我正在开发一个基于 Next.js 13 的项目,已安装了 MUI,但是 VS Code 不提供从 @mui/material 库进行自动导入。如截图所示。

MUI自动导入建议在VS Code中不起作用,Next.js 13项目中。

在这个文件夹中,从其他库进行的自动导入正常工作。在不基于 Next.js 13 的其他项目中,也可以正常从 MUI 进行自动导入。
请告诉我如何解决这个问题?

以下是我的 tsconfig.json 文件,如果有用的话:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

感谢关注!

英文:

I'm working on a Next.js 13 project with MUI installed and VS Code doesn't offer auto imports from the @mui/material library. This is shown in the screenshot.

MUI自动导入建议在VS Code中不起作用,Next.js 13项目中。

Auto imports from other libraries work in this folder. In other projects that are not based on Next js 13, auto imports from MUI also work.
Please tell me how can I fix this?

Here is my tsconfig.json if it may help:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

Thanks for attention!

答案1

得分: 1

"It's looking normal. But sometimes need again run VSCode typescript engine when after add new packages.

  1. shift+cmd+p
  2. 选择 Typescript Reload

Note: 请确保你在 VSCode 中处于正确的文件夹路径。如果你在 VSCode 中启动了错误的项目路径,你将无法看到自动导入的项目包。

也许这个问题不仅与 MUI 有关,也许 这个文档 能帮助你。

英文:

It's looking normal. But sometimes need again run VSCode typescript engine when after add new packages.

  1. shift+cmd+p
  2. Select Typescript Reload

Note : You have to sure you are at correct folder path on VSCode. If you started wrong project path on VSCode you can't see your project packages with auto imports.

Also this problem isn't relational with only MUI, maybe this document could help you.

huangapple
  • 本文由 发表于 2023年5月28日 15:15:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定