原因是typescript只能理解.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
}
把以上内容放入env.d.ts
第二步
将tsconfig.json 中的strict从true改为false
这样就解决了路径报红的原因