如何解决vue3项目中Vue Language Features插件错误提示

728 阅读1分钟

问题

在VSC中创建Vue3项目中总是会提示一些错误的提示虽然不影响项目运行,但很烦人。

b7007e5aaac325a077323edcf9b7104.png

官方对此说明是由于项目的依赖包中存在与Vue Language Features的冲突,那么如何解决呢?

解决

1.首先我们需要在项目中安装一个依赖包

npm i -D @types/react@file:stub/types__react

然后再在package.json中加入如下代码

"@types/react": "file:stub/types__react",

之后我们再创建shims.d.ts文件加入如下代码

declare namespace React {
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
    class?: any
  }
}

然后将文件放入.vscode中重启VSC即可

2c8f5a34f8231aa69ed60cb1178aa0d.png