我正在尝试将服务人员包括在我的angular 7应用程序中。 我为此使用了以下命令:
ng add @angular/pwa
我的灯塔报告说:
Current page does not respond with a 200 when offline
要解决灯塔报告中的上述问题,我在ngsw-config.json文件中添加了网站网址。
我的ngsw-config.json文件:
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
],
"urls": [
"https://getcoursetube.com/**"
]
}
}
]
}
但是在那之后,我得到了以下错误:
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
at Driver.<anonymous> (ngsw-worker.js:2353)
at Generator.next (<anonymous>)
at fulfilled (ngsw-worker.js:1772)
并且灯塔报告仍然显示当前页面在脱机时没有响应200