尝试将此作为扩展程序运行时出现此错误,任何想法?
拒绝执行内联脚本,因为它违反了以下内容 内容安全策略指令:“script-src'self' https://cdn.firebase.com https://*.firebaseio.com“。或者是 'unsafe-inline'关键字,哈希 ('sha256-SDElGe7fYNO4sezC + axo6JiF5P5uY6qAiaLldxOYZXk ='),或者一个随机数 ('nonce -...')是启用内联执行所必需的。
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script>
<script>
// Initialize Firebase
var config = {
apiKey: "**",
authDomain: "**",
databaseURL: "**",
projectId: "**",
storageBucket: "**",
messagingSenderId: "**"
};
firebase.initializeApp(config);
</script>
<script defer type="text/javascript" src="js/app.js"></script>
</head>
<body>
<div id="myApp">
<input id="name" type="text" name="name" placeholder="Name"> <br>
<input id="birth" type="text" name="birth" placeholder="Birthdate">
<input id="submit" type="submit" value="Go" name="submit">
</div>
<div id="births" class="births"></div>
</body>
</html>
的manifest.json
{
"name": "Test",
"manifest_version": 2,
"version": "0.1",
"content_security_policy": "script-src 'self' https://cdn.firebase.com https://*.firebaseio.com; object-src 'self'",
"browser_action": {
"default_title":"Test",
"default_popup": "index.html"
},
}
答案 0 :(得分:0)
此视频 here 可能对您有所帮助...我花了几个小时试图找出解决方法
答案 1 :(得分:-1)
您无法仅从包中加载来自网络的代码。这是因为黑客可以将该Javascript用作家庭基地as shown here.
Rescource(S): https://developer.chrome.com/extensions/contentSecurityPolicy