热卖商品
新闻详情
Chrome 开发工具之 Application - 爱码网
来自 : www.likecs.com/default/index/s
发布时间:2021-03-25
const sw = navigator.serviceWorker .register(\'/testhtml/sw.js\', { scope: \'/testhtml/\' }) .then(function(reg) { if (reg.installing) { console.log(\'Service worker installing\') } else if (reg.waiting) { console.log(\'Service worker installed\') } else if (reg.active) { console.log(\'Service worker active\') reg.update() .catch(function(error) { console.log(\'Registration failed with \' + error) navigator.serviceWorker.ready.then(sw = { return sw.sync.register(\'hello-sync\') navigator.serviceWorker.ready.then(async sw = { const bgFetch = await sw.backgroundFetch.fetch(\'custom-fetch\', [\'1.jpg\'], { title: \'download 1.jpg\', icons: [ sizes: \'300x300\', src: \'2.jpg\', type: \'image/jpg\'}sw.js:
图中 Sync 功能可以触发 Background Sync 事件,并记录到对应面板列表中。
self.addEventListener(\'install\', event = { event.waitUntil( caches.open(\'v1\').then(cache = { return cache.addAll([ \'/testhtml/test.html\', \'/testhtml/test.css\', \'/testhtml/test.js\', \'/testhtml/2.jpg\'self.addEventListener(\'sync\', event = { if (event.tag == \'hello-sync\') { console.log(\'receive hello-sync\')self.addEventListener(\'fetch\', event = { event.respondWith( caches.match(event.request).then(response = { if (response !== undefined) { return response } else { return fetch(event.request) .then(response = { let responseClone = response.clone() caches.open(\'cache_1\').then(cache = { cache.put(event.request, responseClone) return response .catch(() = {})})Service Workers:
图中 Sync 功能可以触发 Background Sync 事件,并记录到对应面板列表中。
本文链接: http://keychrom.immuno-online.com/view-770883.html
发布于 : 2021-03-25
阅读(0)
最新动态
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25