- 编辑器:Webstorm
- 项目技术栈:vite+vue+ts
- 解决
1.vite.config.js设置别名
2.src下创建globals.d.tsresolve: { alias: { '@': path.resolve(__dirname, './src'), }, },
3.tsconfig.json添加别名 将.d.ts文件导入//通用声明 // Vue declare module '*.vue' { import { DefineComponent } from 'vue'; const component: DefineComponent<{}, {}, any>; export default component; }
4.重启编辑器{ "compilerOptions": { "baseUrl": "./", "paths": { "@/*": ["src/*"] } }, "include": ["src/**/*.d.ts", "src/types/**/*.d.ts"], }
Vue: Cannot find module @/xx/xx/xx.vue or its corresponding type declarations.
于 2023-11-23 11:45:32 首次发布