简体   繁体   English

如何在加载大页面-data.json 时在 Gatsby 站点上显示加载器?

[英]How to show loader on a Gatsby site while large page-data.json is loading?

I'm loading 2000+ video cards in a big list (that loads/functions quickly with react-window).我正在一个大列表中加载 2000 多个视频卡(使用 react-window 快速加载/运行)。 This main page can take a while to load the first time but then does fine after that (it's loading then cache-ing 10MB of data).这个主页在第一次加载时可能需要一段时间,但之后就可以了(它正在加载然后缓存 10MB 的数据)。 I'm trying to show a spinner (loading animation) while the data loads.我试图在数据加载时显示一个微调器(加载动画)。 In other sites, I've simple done a basic conditional to test to see if the length of the items array I'm loading is greater than 0. But with Gatsby, it seems like the site loads the array just fine so array.length doesn't work here.在其他站点中,我简单地做了一个基本条件来测试我正在加载的 items 数组的length是否大于 0。但是对于 Gatsby,似乎站点加载数组就好了,所以 array.length在这里不起作用。

Is there some kind of event or way to test that the page-data.json is loaded?是否有某种事件或方法来测试 page-data.json 是否已加载?

考虑使用官方的 nprogress 插件https://www.gatsbyjs.org/packages/gatsby-plugin-nprogress/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM