我正在尝试制作一个使用 jQuery 的外部 javascript 文件的 chrome 扩展。但我不断收到这个愚蠢的错误。
Screenshot of error in chrome inspector.
感谢任何帮助,谢谢!
popup.js
$(document).ready(function() {
$.ajax({url: "http://www.google.com", success: function(result) {
$("#report-details").html(result);
}});
});
popup.html
<!doctype html>
<html>
<head>
<title>TEST</title>
<script src="popup.js"></script>
<script src='./js/jquery.min.js'></script>
<script src='./js/jquery.js'></script>
</head>
<body>
<h1>TEST</h1>
<div id="report-details">
</div>
</body>
</html>
list .json
{
"manifest_version": 2,
"name": "my ext",
"description": "fun ext",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
],
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js": ["js/jquery.min.js"]
}
]
}
非常感谢任何帮助。 (如果这是一个菜鸟错误,我深表歉意)
最佳答案
在加载 popup.js 之后首先加载 Jquery 插件
<script src='./js/jquery.min.js'></script>
<script src="popup.js"></script>
注意:不需要加载2个jquery Plugin
关于javascript - chrome 扩展未捕获 ReferenceError : $ is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30750125/