为什么vscode看不到服务工作者接口对象?
lack of auto completion
虽然浏览器显示它们仍在那里
presence of object logged in browser
如何解决这个问题?
整个服务人员代码:
self.addEventListener('install', event => {
console.log('V1 installing…');
event.waitUntil(
caches.open('static-v1').then(cache => cache.add('/cat.png'))
);
});
self.addEventListener('activate', event => {
console.log('V1 now ready to handle fetches!');
});
self.addEventListener('fetch', event => {
const url = new URL(event.request.url);
if (url.origin == location.origin && url.pathname == '/dog.png') {
event.respondWith(caches.match('/cat.png'));
}
if (url.origin == location.origin) {
console.log("Clients object: ", clients);
}
});