📜  导航预加载示例工作框 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:13.135000             🧑  作者: Mango

代码示例2
self.addEventListener('activate', (event) => {
  if (self.registration && self.registration.navigationPreload) {
    event.waitUntil(
      self.registration.navigationPreload.enable().then(() => {
        // Defaults to Service-Worker-Navigation-Preload: true if not set.
        if (headerValue) {
          self.registration.navigationPreload.setHeaderValue(headerValue);
        }
      })
    );
  }
});