NUXT 2.14:等到内部的所有内容都将完成
我有一个问题。在Nuxt的fetch
挂钩中,我有一些异步调用,这些调用由 nuxt content api。
然后在安装
挂钩中使用了一些这些数据。
但是,当nuxt在fetch
内处理第一个请求时,控制流程传递到已安装
挂钩,因此没有必要的数据。
是的,我尝试使用之类的东西,如果(!返回;
,但显然已安装
仅调用一次。有人知道我该如何迫使nuxt等待吗?顺便说一句,该应用程序正在使用静态站点生成,并且该组件具有属性fetchonserver
设置为false。
I have a question. Inside Nuxt's fetch
hook I have some asynchronous calls that are performed by Nuxt content API.
Some pieces of this data are then used inside mounted
hook.
But while Nuxt handles first request inside fetch
, the control flow passes to the mounted
hook and hence there's no needed data.
Yes, I tried uses something like if (!this.$fetchState.pending) return;
but obviously mounted
is called only once. Does anybody knows how can I force Nuxt to wait? Btw, the app is using static site generation and the component has property fetchOnServer
set to false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其留在此处以供将来参考(我自己):在您的
fetch
函数中,您可以将实例变量设置为一旦远程调用完成后将解决的承诺,然后等待已安装。
Leaving this here for future reference (by myself): in your
fetch
function you can set an instance variable to a promise that will be resolved once the remote call is complete, and then await that variable inmounted
.