配置路由的时候,将引入的路径改为了@的方式,结果开始报错,如上图所示,貌似也不影响功能,但是影响心情,搜了一下解决办法:
1. src文件夹创建vite-env.d.ts
2. 添加下面代码:
declare module '*.vue' {
import { Component } from 'vue'; const component: Component; export default component;
}
如图:
不报错了,欢欢喜喜继续开发
参考链接:错误:找不到模块“@/views/login/index.vue”或其相应的类型声明。ts(2307)_找不到模块“vue”或其相应的类型声明-CSDN博客