Pan*_*yer 17 javascript reactjs
尝试为我的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)
Grz*_*icz 22
对于那些仍然有这个问题的人.解决方案是使用window.self而不是简单self.
Fra*_*ion 12
您可以self从no-restricted-globals规则中明确删除或简单地禁用包含selfusingeslint-disable-line或的行的规则eslint-disable-next-line:
self.addEventListener('install', function (event) { /* eslint-disable-line no-restricted-globals */
...
Run Code Online (Sandbox Code Playgroud)
或者
/* eslint-disable-next-line no-restricted-globals */
self.addEventListener('install', function (event) {
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9669 次 |
| 最近记录: |