📜  service worker.js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:41.948000             🧑  作者: Mango

代码示例1
if ('serviceWorker' in navigator) {  window.addEventListener('load', function() {    navigator.serviceWorker.register('/sw.js').then(function(registration) {      // Registration was successful      console.log('ServiceWorker registration successful with scope: ', registration.scope);    }, function(err) {      // registration failed :(      console.log('ServiceWorker registration failed: ', err);    });  });}