我制作了一个网络应用程序,并在我的应用程序中使用了服务工作者 在线时一切正常.当我们第一次运行应用程序时,这些文件都被缓存了.但是当它离线时我得到这个错误.
Uncaught (in promise) TypeError: Failed to fetch
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出现这个错误!
我使用pwabuilder.com将服务工作者和清单添加到Web应用程序.
这是pwabuilder-sw.js文件:
self.addEventListener('install', function(event) {
event.waitUntil(preLoad());
});
var preLoad = function() {
console.log('[PWA Builder] Install Event processing');
return caches.open('pwabuilder-offline').then(function(cache) {
console.log('[PWA Builder] Cached index and offline page during
Install');
return cache.addAll([
'/manup.js',
'pwabuilder-sw-register.js',
'pwabuilder-sw.js',
'manifest.json',
'/js/angular.min.js',
'/js/script.js',
'/js/materialize.min.js',
'/css/materialize.min.css',
'/css/style.css',
'/offline.html',
'/index.html'
]);
});
}
self.addEventListener('fetch', function(event) {
console.log('The service worker is serving the asset.');
event.respondWith(checkResponse(event.request).catch(function() {
return returnFromCache(event.request)
}));
event.waitUntil(addToCache(event.request));
});
var checkResponse = function(request) {
return new Promise(function(fulfill, …Run Code Online (Sandbox Code Playgroud) 如何给div添加分页功能。
应用程序组件.html
<div>
<div *ngFor="let clg of colleges$">
<h3>{{clg.name}}</h3>
</div>
<mat-paginator [length]="100" [pageSize]="10" [pageSizeOptions]="[5, 10, 25,
100]"></mat-paginator>
</div>
Run Code Online (Sandbox Code Playgroud)