我做了一个简单的
ng new cx --service-worker
cd cx
第一个观察:我没有看到在 package.json 或任何模块条目等中使用它安装的服务工作者是一个错误吗?
我继续前进并使用
ng add @angular/pwa
这增加了服务工作者。但是,在运行它时,我在控制台中看到错误:
Manifest.json
Unexpected error line 1 col 1, unexpected token;
mnifest.json
{
"name": "cx",
"short_name": "cxa",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "assets/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "assets/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "assets/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "assets/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
我验证了该文件确实存在于 src/ 位置且内容非空。我暂时保留了这些默认设置。
ng -v
Angular CLI: 6.0.1
Node: 8.11.1
OS: darwin x64
Angular: 6.0.2