我在Mozilla中遇到此错误,我不知道原因:
ServiceWorker将承诺传递给FetchEvent.respondWith() 在尝试获取时拒绝了' TypeError:NetworkError 资源。
serviceWorker.js
self.addEventListener('install', e => {
const timeStamp = Date.now();
e.waitUntil(
caches.open('Print a Banner').then(cache => {
return cache.addAll([
`/`
])
.then(() => self.skipWaiting());
})
);
});
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request, {ignoreSearch: true}).then(response => {
return response || fetch(event.request);
})
);
});
任何想法或解决方案? 谢谢。