【发布时间】:2016-05-15 17:39:51
【问题描述】:
我正在按照本教程构建一个新的选项卡 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 a 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?
【问题讨论】:
-
将
browser.min.js作为文件包含在您的扩展中,并链接到该文件。 (我觉得这应该是另一个问题的重复,但我找不到它。)您也可以在清单中使用"content_security_policy",但这更复杂。
标签: javascript google-chrome google-chrome-extension reactjs babeljs