为什么在站点加载时多次调用 nuxtServerInit

编程入门 行业动态 更新时间:2024-10-27 16:34:55
本文介绍了为什么在站点加载时多次调用 nuxtServerInit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在处理 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 22:56:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   站点   nuxtServerInit

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!