为什么在站点加载时多次调用 nuxtServerInit [英] Why nuxtServerInit is called multiple times on site load

查看:41
本文介绍了为什么在站点加载时多次调用 nuxtServerInit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理 nuxt-edge + auth.nuxt + vuex 项目和 nuxtServerInit 方法我只在控制台中记录一条消息.当站点重新加载时,消息会被打印多次.这似乎只发生在 dev 模式下.

I am working on nuxt-edge + auth.nuxt + vuex project and in the nuxtServerInit method of the store I am only logging a message in the console. When the site is reloaded the message gets printed multiple times. This seems to happen only in dev mode.

推荐答案

任何时候从您的服务器请求资产导致错误,Nuxt 都会为每个文件呈现并返回一个单独的错误.错误页面被视为 Nuxt 中的任何其他页面.这意味着 nuxtSeverInit 会为您的初始请求调用,并为服务器上的每个错误请求再次调用.

Any time an asset is requested from your server that results in an error, Nuxt will render and return an individual error for each file. Error pages are treated like any other page in Nuxt. This means nuxtSeverInit gets called for your initial request and gets called again for each error request on the server.

检查您的网络请求以追踪从您的 Nuxt 服务器请求的每个错误资产.

Check your Network requests to track down each error asset that is requested from your Nuxt server.

这篇关于为什么在站点加载时多次调用 nuxtServerInit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆