简体   繁体   English

React-Snap上的客户端AJAX请求

[英]Client Side AJAX Request on React-Snap

I am using react-snap package with my React Application which can generate basically a static form of my whole application. 我在我的React Application中使用react-snap包,它基本上可以生成整个应用程序的静态形式。 But it actually crawls all the AJAX data and fetches them then build the static site. 但实际上,它会爬网所有AJAX数据并获取它们,然后构建静态站点。 But I want react-snap to skip some of the AJAX requests. 但是我想用react-snap跳过一些AJAX请求。 I want my application to make those request whenever the client opens the static page. 我希望我的应用程序在客户端打开静态页面时发出这些请求。

您可以检测预渲染阶段,例如if (navigator.userAgent === "ReactSnap") { ... } ,并在应用程序中跳过AJAX请求。

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

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