3

为了制作 PWA,我正在遵循 Angular 的最佳实践。在进行生产构建 ( ng built --prod --aot) 之后。我也在 dist 上运行localhost:(npm run dev"dev": "lite-server"。当浏览器加载时,我在控制台中收到错误:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-EzX1NiGgmo59Hi8wZ/thoAxnVbkTfzIAgnVddwzUO3Y='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

我尝试添加到 index.html: <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-eval' 'unsafe-inline';">

我究竟做错了什么?

4

1 回答 1

1

请在路由器模块中像这样

RouterModule.forRoot(rootRouterConfig, { useHash: true})
于 2019-05-09T10:30:23.870 回答