尝试为我的 PWA 应用程序编写一个 Service Worker,发现了这个错误。我为服务 worker 使用了 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);
})
);
});
最佳答案
您可以从 no-restricted-globals 中显式删除 self
规则或简单地使用 eslint-disable-line
或 eslint-disable-next-line
禁用包含 self
的行的规则:
self.addEventListener('install', function (event) { /* eslint-disable-line no-restricted-globals */
...
或者
/* eslint-disable-next-line no-restricted-globals */
self.addEventListener('install', function (event) {
...
关于javascript - 意外使用 'self' no-restricted-globals React,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44292520/