我正在按照本教程构建一个新的选项卡 chrome 扩展.. https://facebook.github.io/react/docs/tutorial.html
但是当我附上
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
按照教程的建议使用 babel 渲染 JSX,我从浏览器控制台收到此错误。
“browser.min.js:4 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' blob :文件系统:chrome-extension-resource:“。” screenshot of the error
我知道这违反了 CSP 指令,但我又该如何使用 babel 来使用最新的 reactJS?
最佳答案
在你的 manifest.json 文件中,你可以尝试设置
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
我从here得到了答案.这为我消除了错误,但我对它的了解还不足以了解其他含义,抱歉。
关于javascript - 在 Chrome 扩展中使用 React js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35229330/