我正在遵循angular的最佳实践来制作PWA。完成生产构建之后(ng built --prod --aot
。我也在localhost
上从dist运行: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';">
我在做什么错了?
答案 0 :(得分:0)
请在路由器模块中像这样实现
RouterModule.forRoot(rootRouterConfig, { useHash: true})