reactjs - 在 NextJS 中使用绝对导入后 VSCode 自动导入不起作用

标签 reactjs visual-studio-code next.js auto-import

在我的 NextJS 项目中创建 jsconfig.json 文件后,我的 VSCode 自动导入(使用 control + 空格键)无法正常工作。

这是我的 json:

{
  "compilerOptions": {
    "baseUrl": "."
  },
  "include": ["."]
}

我正在使用 next 10.2.3 和 vscode 1.57.1​​。如果我删除 jsconfig.json 文件,自动导入工作正常..

有人知道为什么吗?

最佳答案

我认为您还需要添加扩展。 以下是我的应用如何使用它,并且我正确地获得了自动导入建议。

"baseUrl": ".",
"include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],

关于reactjs - 在 NextJS 中使用绝对导入后 VSCode 自动导入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68038766/

相关文章:

javascript - 如何将数据从组件传递到 getServerSideProps

css - css 的 react-big-calendar 导入失败

reactjs - Elm 与 React : why no lifecycle functions in Elm?

reactjs - 在 Jest 中使用范围包

visual-studio-code - Vscode API - 自定义 View 容器未显示

visual-studio-code - 接受未出现在 VS Code 中的传入更改(VS Code 版本 1.61.2)

ubuntu - VS 代码不再打开

javascript - 将 html 从变量返回到 React <input/> 的值中

javascript - Next.js 链接刷新页面

javascript - 如何在 Next.js 中获取 _app.js 的状态?