更新时间:2021-07-04 03:24:30
From the Chrome extension CSP docs:
内联JavaScript将不会执行。此限制禁止内联
< script>
块和内联事件处理程序(例如< button onclick =...>
)。
Inline JavaScript will not be executed. This restriction bans both inline
<script>
blocks and inline event handlers (e.g.<button onclick="...">
).
您不能在您的扩展HTML中包含内嵌脚本,如:
You cannot have inline scripts in your extension HTML like:
<script>alert("I'm an inline script!");</script>
<button onclick="alert('I am an inline script, too!')">
相反,您必须将脚本放入单独的文件中:
Rather, you must place your script into a separate file:
<script src="somescript.js"></script>