Kei*_*ith 14 javascript progressive-web-apps manifest.json
我有一个manifest.json,它有一个start_url属性,我想指向我的单页面应用程序的第一个文件.
这是index.html,它是网站的根源.我希望这是start_url,但该文件永远不会被要求作为URL.
我如何指向start_url网站的相对根?
例如,假设该网站是在https://example.com什么应的值start_url是https://example.com/manifest.json?我希望PWA从而开始https://example.com而不是 https://example.com/index.html.PWA可能放在不同的域上,因此start_url需要是相对的,而不是绝对的.
您的清单文件中的start_url应该设置为以下内容。
"start_url": "/"
Run Code Online (Sandbox Code Playgroud)
来源:https://developers.google.com/web/fundamentals/integration/webapks
If you are running in the root of a site, for instance https://example.com/manifest.json or https://test.example.com/manifest.json you can use "start_url": "/".
However, this will also map https://example.com/test/manifest.json to https://example.com/, which fails because it's in a folder outside the scope of the manifest.
Instead, if you are using a sub-directory you need to set both a scope and the start_url:
"start_url": "./"
"scope": "."
Run Code Online (Sandbox Code Playgroud)
This will cause https://example.com/test/manifest.json to map to https://example.com/test/ as expected.