gpt4 book ai didi

javascript - "Manifest: Line: 1, column: 1, Syntax error"

转载 作者:行者123 更新时间:2023-12-03 06:36:06 27 4
gpt4 key购买 nike

我正在使用 Vue.js 创建渐进式 Web 应用程序 (PWA) 作为学校项目。每当我使用 Azure 托管网站时,我都会收到“ list :行:1,列:1,语法错误”。
我在本地主机上没有这个问题......

Chrome DevTools回复:

/manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
/manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
manifest.json:1 GET https://serviceworkerspike.azurewebsites.net/manifest.json 404
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.

如何纠正错误?

<小时/>

我的 index.html 中有以下行:

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

这是我的 manifest.json 文件:

{
"name": "MessageBoardUCN",
"short_name": "MessageBoardUCN",
"theme_color": "#ff095a",
"background_color": "#feaaee",
"display": "standalone",
"start_url": "/index.html",
"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
}

我尝试过的

  • nameshort_name 属性中使用小写字母 - messageboarducn

  • starturl 设置为托管 URL 或“/”。

  • manifest.json 文件移动到根目录或 src/ 目录,但其他指南告诉我它应该位于与index.html,而 public/ 是默认值。

This is my file structure .

托管 URL https://serviceworkerspike.azurewebsites.net ,不再起作用了。

最佳答案

如果您的 list 文件位于根级别(index.html 所在的位置),您可以像 <head> 中的以下内容一样引用它index.html 文件的标签:

<link rel="manifest" crossorigin="use-credentials" href="manifest.json"/>

加上 list 文件中的 startUrl 应该是:

"start_url": "/"

当您将根作为起点时。

否则,如果您要使用特定的基本 URL 来为您的应用程序提供服务,则应将其反射(reflect)在 startUrl 属性中:

Example: 

--> www.myapp.com/my-other-url-part/

Use:
"start_url": "/my-other-url-part/"

Or simply:
"start_url": "./" <-- This would match any base-href != "/"

然后,您应该将 Web 服务器设置为自动提供 index.html 文件(这通常是默认启用的)

关于javascript - "Manifest: Line: 1, column: 1, Syntax error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59068699/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com