webstorm vue3+ts报错:Cannot find module ‘@/views/xxx.vue‘ or its corresponding type declarations

It means that the corresponding module "@/views/xxx.vue" or its corresponding type declaration cannot be found

Because ts can only parse .ts files and cannot parse .vue files

The solution is very simple. At the beginning, env.d.ts is an empty file. We can introduce the following code into the env.d.ts of the project:

declare module '*.vue' {
  import { DefineComponent } from "vue"
  const component: DefineComponent<{}, {}, any>
  export default component
}

Add the above code, no error will be reported.

Guess you like

Origin blog.csdn.net/weixin_52020362/article/details/130665069