The component cannot be found in vue3.0 or the corresponding type declaration cannot be found. How to deal with it

How to solve the problem that the component cannot be found in vue3.0 or the corresponding type declaration cannot be found?

  • Here is the error, the reason for the error
  • Error reporting is the impact of ts
  • The component module could not be found or the corresponding type declaration could not be found
  • Typescript can only understand .ts files, not .vue files
  • insert image description here
  • Solution
    Create a file with the suffix .d.ts in the project root directory or src folder, and write the following content:
  •  declare module '*.vue' {
          
          
       import {
          
           ComponentOptions } from 'vue'
       const componentOptions: ComponentOptions
       export default componentOptions
     }
    
  • insert image description here
  • Of course the name is arbitrary
  • Many people think that saving is enough => just restarting the project
    requires ctrl+c to terminate the project and restart the project
    insert image description here

Supongo que te gusta

Origin blog.csdn.net/weixin_53532986/article/details/118572689
Recomendado
Clasificación