vue3 vite 引入组件报错 Failed to resolve import ..... Does the file exist?

vue yekong 4299℃

最近在学习vue3,为了更好的实践,所以着手将手头以前做过的项目升级为vue3来对比看看都有哪些变化。于是将手头的项目数据大屏视频监控智能分析系统,用来做实践项目。

然后遇到了第一个问题

使用vite引入组件的时候会报错误

Failed to load url /src/components/headtop (resolved id: /src/components/headtop). Does the file exist?

解决办法

把完整的组件名包括后缀一起写进去就可以了。

修改前

缺少.vue

import headtop from '@/components/headtop'

修改后

补全.vue就可以了。

import headtop from '@/components/headtop.vue'

重新运行就可以了。

喜欢 (4)