Manifest.json用于渐进式Web应用程序不起作用 [英] Manifest.json for progressive web app not working

查看:314
本文介绍了Manifest.json用于渐进式Web应用程序不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使manifest.json文件可用于我的Web应用程序.不幸的是,它无法正常工作.我在chrome devtools中收到以下错误:

I am trying to get the manifest.json file working for my web app. Unfortunately it is not working right. I am receiving the following error in the chrome devtools:

行:1,列:1,意外令牌.

Line: 1, column: 1, Unexpected token.

我非常确定JSON是有效的,但它可能与.我在这里做什么错了?

I am pretty sure that the JSON is valid but it probably has something to do with the path in the html-head. What am I doing wrong here?

我是这样在我的html中链接它的:

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

清单清单如下:

{
  "short_name": "Tabbs Web App",
  "name": "Tabbs Web App",
  "description": "Tabbs is an digital booking service for the night life scenery",
  "icons": [
    {
      "src": "favicon.png",
      "sizes": "1024x1024",
      "type": "image/png"
    }
  ],
  "start_url": "./index.html",
  "display": "fullscreen",
  "theme_color": "#F5C33E",
  "background_color": "#ffffff"
}

这是我的地图结构:

希望有人可以找到问题!干杯!

Hopefully someone can find the issue! Cheers!

推荐答案

第一个问题,您的start_url无效.您应该学会使用如何生成Lighthouse报告,以帮助自己找到造成此类问题的原因.

First issue, your start_url is not valid. You should learn to use how to generate Lighthouse report to help yourself find such issue cause.

与其像这样以起始URL开头

Instead of having start URL as this

"start_url": "./index.html",

尝试此操作或直接删除."从上面的URL进行尝试,这完全取决于您的构建和托管,manifest和index.html位置等.因此,您必须尝试多个并查看有效的方法.

Try this or simply remove "." from the above URL and try, it all depends on your build and hosting, manifest and index.html locations, etc. So you have to try multiple and see what works.

"start_url": "http://tabbs-web-app.herokuapp.com/discover/home",

我没有收到您提到的错误. 我得到的是以下内容,这是因为您的网站从非HTTPS请求中加载了内容.如果要使站点成为PWA站点,请通过HTTPS转换所有HTTP请求并添加服务工作者.

I'm not getting the error that you have mentioned. I'm getting the below one though, which is because your site loads content from non HTTPS requests. If you are targeting to make your site a PWA one, convert all HTTP request over HTTPS and add a service worker.

Site cannot be installed: the page is not served from a secure origin

以下是Lighthouse的审计报告,其中指出清单不是

Here is the Lighthouse audit report, which says Manifest is not

这篇关于Manifest.json用于渐进式Web应用程序不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆