[英]How to include jQuery in my manifest.json file for a chrome Extension
I have read many answers on here, but none of the solutions have worked. 我在这里阅读了许多答案,但是没有一种解决方案有效。 I know I am doing something wrong, so I would be very grateful if somebody had the time to help me here.
我知道我做错了,所以如果有人有时间在这里帮助我,我将不胜感激。
File-name for my JS-file is main.js 我的JS文件的文件名为main.js
My relevant HTML-Code: 我相关的HTML代码:
<script src="js/main.js" src="jquery.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
My entire manifest.json: 我的整个manifest.json:
"name": "Roasts Tab",
"manifest_version": 2,
"description": "A fire roast every time you open a new tab in Chrome",
"version": "0.0.0.1",
"permissions": ["management"],
"chrome_url_overrides": {
"newtab": "index.html"
},
"icons": {
"128": "icon.png"
}
}
Thanks in advance. 提前致谢。
You have two src attributes on your first script tag... It looks like you need to remove the src="jquery.js"
one, since you're loading jQuery from the cdn. 您的第一个脚本标签上有两个src属性...看来您需要删除
src="jquery.js"
一个,因为您是从cdn加载jQuery的。
Also move your own script tag below the jQuery cdn script tag. 还要将您自己的脚本标签移动到jQuery cdn脚本标签下方。 As it is now, it runs your scripts first, and then loads jQuery after, so your scripts do not have access to the jQuery functions.
到目前为止,它先运行您的脚本,然后再加载jQuery,因此您的脚本无权访问jQuery函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.