我使用 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 行代码,所以我认为在这里发布它没有意义。
不知道我在这方面缺少什么。