vue3+vite在main.ts文件中引入./App.vue报错(./App.vue不是模块)

问题

如下图:
在这里插入图片描述

方法一

下载TypeScript Vue Plugin (Volar)插件就不报红了,看它的描述应该就是ts文件可以识别vue文件。
在这里插入图片描述

方法二

在src文件夹下添加env.d.ts文件,添加以下代码:

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
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_57809042/article/details/132251700
今日推荐