vue3+vite introduces ./App.vue into the main.ts file and reports an error (./App.vue is not a module)

question

As shown below:
Insert image description here

method one

Downloading the TypeScript Vue Plugin (Volar) plug-in will not cause red flags. Judging from its description, it should be that ts files can recognize vue files.
Insert image description here

Method Two

Add the env.d.ts file under the src folder and add the following code:

declare module '*.vue' {
    
    
  import type {
    
     DefineComponent } from 'vue'
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
  const component: DefineComponent<{
    
    }, {
    
    }, any>
  export default component
}

Insert image description here

Guess you like

Origin blog.csdn.net/m0_57809042/article/details/132251700