问题
在VSC中创建Vue3项目中总是会提示一些错误的提示虽然不影响项目运行,但很烦人。
官方对此说明是由于项目的依赖包中存在与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即可