0
<!DOCTYPE html>
...
<head>
<script type="module">
   import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
   const el = document.createElement('pwa-update');
   document.body.appendChild(el);
</script>
...
</head>

我尝试根据本文档(https://github.com/pwa-builder/pwabuilder-web/blob/V2/src/assets/next-steps.md)将 PWA 应用到我的站点。但是,这并没有按预期工作,查看浏览器的调试工具后,我发现我需要更改swpath.

我尝试了各种方法来更改 的值swpath,但都失败了,并且存储库仅声明 的值swpath存在,但没有告诉我如何更改它。我想知道如何更改swpath.

4

1 回答 1

0
<!DOCTYPE html>
<head>
...
<script type="module">
   import 'https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate';
   const el = document.createElement('pwa-update');
   el.swpath = "/pwabuilder-sw.js";
   document.body.appendChild(el);
</script>
...
</head>

我用上面的代码解决了这个问题。

于 2022-01-26T05:01:22.023 回答