简体   繁体   English

如何使用sw-toolbox sw-precache库为服务工作者显示自定义404页面

[英]How to show custom 404 page using sw-toolbox sw-precache libraries for service-worker

I have an SPA which makes various http calls to get content from third party service and show content on the page. 我有一个SPA,可以进行各种http调用以从第三方服务获取内容并在页面上显示内容。 How do I configure /use sw-toolbox and sw-precache libraries, such that if http call fails due to being offline it shows a custom 404 page. 如何配置/使用sw-toolbox库和sw-precache库,这样,如果http调用由于脱机而失败,则会显示一个自定义404页面。

you can achieve this b specifying a default router using 您可以通过使用以下命令指定默认路由器来实现

toolbox.router.default = "yourDefaultRoute";

more information on this can be found here : https://googlechrome.github.io/sw-toolbox/usage.html#the-default-route 有关更多信息,请参见: https : //googlechrome.github.io/sw-toolbox/usage.html#the-default-route

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

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