一点人生经验,关于Vite热更新失效

4,106 阅读1分钟

第一种:route配置中文件大小写的问题

千言万语先来一句话:注意route中配置的文件大小写

大小写写错了照样可以运行,但是不会热更新!

第二种:循环引用引发的bug

提示错误详细: ReferenceError: can't access lexical declaration 'xxx' before initialization [hmr] Failed to reload /src/... This could be due to syntax errors or importing non-existent modules. (see errors above)

解决方案

import {router} from "@/router"换成

import { useRouter } from "vue-router";
const router = useRouter()