【问题标题】:Receiving error with manifest.json (unexpected token)manifest.json 接收错误(意外的令牌)
【发布时间】:2018-09-23 23:21:43
【问题描述】:

我正在尝试让我编写的应用程序渐进式。

我收到指向 manifest.json 文件的错误...

错误提示,Line: 1, Column: 1, Unexpected Token

这是我的清单文件

{
  "manifest_version": 2,
  "name": "Blah Blah Blah",
  "short_name": "Analysis App",
  "theme_color": "#fddb2f",
  "background_color": "#fddb2f",
  "display": "standalone",
  "Scope": "/",
  "start_url": "/",
  "version": "1",
  "icons": [
    {
      "src": "images/icons/icon-72x72.png",
      "sizes": "72x72",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-96x96.png",
      "sizes": "96x96",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-128x128.png",
      "sizes": "128x128",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-144x144.png",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-152x152.png",
      "sizes": "152x152",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-384x384.png",
      "sizes": "384x384",
      "type": "image/png"
    },
    {
      "src": "images/icons/icon-512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "splash_pages": null
}

这就是我在我的 html 中引用它的方式

 <link rel="manifest" href="/manifest.json">

我不知道为什么会出现这个错误??

有人可以帮忙吗?

非常感谢

【问题讨论】:

标签: javascript json manifest


【解决方案1】:

尝试将 href="./manifest.json" 与 "." 一起使用之前 /

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,但解决了 50%。

    我从https://developers.google.com/web/fundamentals/codelabs/your-first-pwapp/ 测试了它的谷歌教程

    当我在 web 服务器上为带有根文件夹的 chrome 设置它时(选择文件夹 = Current/pwa_weather)它可以 100% 工作。我可以像https://localhost:8888 一样访问它。

    但是,当我通过 https://xxxx.azurewebsites.net/pwa_weather 之类的访问将其设置到我的 Azure 时,它​​不起作用。

    我的结论是 menifest.json 必须在 web 根文件夹中。我什至用 utf8bom 文件格式修改 manifest.json 都失败了。另外,用绝对路径修改 index.html,如 , .

    【讨论】:

      猜你喜欢
      • 2019-08-06
      • 2014-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 2015-11-19
      • 2018-08-27
      • 2014-12-07
      相关资源
      最近更新 更多