Angular 6 @angular/pwa - sw 未成功提供清单 start_url

2024-02-17

我使用 Angular 6 和 @Angular/pwa 包构建了一个 PWA。

我一直在尝试解决此问题,但无论我做什么,我都会收到 start_url 错误。我努力了:

  • 使用绝对链接
  • 确保 start_url 在 SW 的范围内(sw 在主文件夹中)
  • 使用文件名“/index.html”,正如我在其他支持线程中看到的那样。
  • 每次都清除所有浏览器历史记录和缓存。
  • 搜索 @angular/pwa 包的 Github 问题
  • 一般在 google 上搜索此 PWA 问题。

这是我的清单:

{
  "name": "BC Doc View",
  "short_name": "BCview",
  "theme_color": "#1976d2",
  "background_color": "#fafafa",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",

这段代码后面只有一堆图标,与本文无关。

我的服务工作者配置:

{
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "BC Doc View",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**"

我使用 ng build --prod 命令实际生成的服务工作线程有 2200 行代码,所以我认为在这里发布它没有意义。

不知道我在这方面缺少什么。


我已经因为这个错误哭了 3 小时,在我将其发布到此处几分钟后,我找到了解决方案。

我一直在将其测试到开发子域中并像 subdomain.domain.com/folder 一样访问它

将所有内容放入主文件夹后,我将获得 100 的 PWA 分数。

https://i.stack.imgur.com/BsYBL.png https://i.stack.imgur.com/BsYBL.png

不过我还没有优化性能。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular 6 @angular/pwa - sw 未成功提供清单 start_url 的相关文章

随机推荐