我真的无法在项目中包含模板分布的分布。由于 Electron 是 headless Chrome ,是否应该将其作为脚本包含在内?
我似乎有关于安全策略的错误
模板版本:
1.12.2
它们在standalone-html中运行良好
index-64aa1cf6.js:2443 Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-imoMl/F66ZbGZfn+J0jtlxdZvr/1ZBs+8ReasI4LBKQ='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
bootstrapLazy @ index-64aa1cf6.js:2443
index-64aa1cf6.js:2888 Refused to load the script 'blob:file:///f7aff0d4-a09c-464c-8344-451ac3a43fba' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
最佳答案
Electron 不是 headless Chrome ,它基于 Chrome 。
您的错误消息告诉您已启用 CSP(内容安全策略),因此加载脚本和内联样式已被阻止。
您可以更改 CSP 规则以允许加载该脚本,或者禁用 CSP(不太安全)。
链接:
问题也可能只是您试图将脚本包含在
blob:file://
中。协议(protocol)。对于阻塞的内联样式,您可以在指令中添加随机数或哈希源(更安全),或使用
'unsafe-inline'
.
关于electron - 如何在 Electron 应用程序中包含模板组件的分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61506122/