大家好,我是服务人员的新手,我正面临这个错误
The FetchEvent for "<My Local URL>" resulted in a network error response: the promise was rejected.
我不知道这是什么意思
这就是当我单击offline
并refresh
从网络选项卡脱机问题时发生的情况
这是我的代码
self.addEventListener('install', function(event)
{
console.log('[Service Worker] Installing Service Worker ...', event);
event.waitUntil(
caches.open('static')
.then(function(cache) {
console.log('[Service Worker] Precaching App Shell');
cache.add('/src/js/app.js')
})
)
});
self.addEventListener('activate', function(event) {
console.log('[Service Worker] Activating Service Worker ....', event);
return self.clients.claim();
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
if (response) {
return response;
} else {
return fetch(event.request);
}
})
);
});
任何线索我都会受到赞赏。