本文主要是介绍Vue: Cannot find module @/xx/xx/xx.vue or its corresponding type declarations.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- 编辑器: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.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!