开发插件选项页时由于引用了vue框架开发前端页面,导致拒绝eval求值问题
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: filesystem:”.
这是浏览器自带的"网页安全政策"(Content Security Policy)导致的;浏览器默认的Content-Security-Policy的安全政策时“ default-src ‘self’ ”。我们可以通过manifest.json重新配置Content Security Policy的配置开启eval功能
// 代码如下,可直接复制 ,"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
注意:修改插件配置文件manifest.json需要重新安装插件才能生效(先卸载再重新导入)