尝试为我的PWA应用程序编写服务工作者,请注意此错误.我使用Google/Mozilla样本作为服务工作者,但无论如何.
var CACHE_NAME = 'test-cache';
var urlsToCache = [
'/'
];
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(CACHE_NAME)
.then(function (cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
Run Code Online (Sandbox Code Playgroud)