[nuxt] error caught during app initialization H3Error: Failed to fetch dynamically imported module
原因
页面跳转没有使用useRouter,使用location.href;或者使用a标签跳转没有使用官方组件NuxtLink等。
解决
1、路由跳转替换
// 在plugins/init.client.js文件
export default defineNuxtPlugin(nuxtApp => {
// window.$route = useRoute()
window.$router = useRouter()
})
location.href = xxx 替换成 $router.push(xxx)
2、a标签替换
<a href="/project">xxx</a>替换成<NuxtLink to="/project">xxx</NuxtLink>
版本
“nuxt”: “^3.15.4”