我真的很困惑。我正在努力理解铬扩展名的文件架构。我正在读这个医生:https://developer.chrome.com/extensions/overview#arch
我的处境:
我希望设置oauth流,以便用户可以在扩展内登录(另一个端点是my后端)。到目前为止,我有这些文件:
background.js
content.js
popup.html
manifest.json其中,我的content.js向background.js发送消息并获得响应。到目前为止还不错!
但是现在,当我阅读oauth的文档时,我很困惑,不知道background.html是什么。它实际上是包含我的background.js的所有js代码的文件吗?但是,如果我将清单中的内容更改为.html,例如:
"background": {
"persistent": false,
"scripts": ["jquery111.js", "background.html"]扩展不再起作用了。在OAuth文档中,它说:
Place the four library files in the root of your extension directory
(or wherever your JavaScript is stored). Then include the .js files in your
background page...
Your background page will manage the OAuth flow.但在架构文档中,它说:
This figure shows the browser action's background page, which is defined by
background.html and has JavaScript code that controls the behavior of
the browser action in both windows.background.html和background.js有什么区别?
发布于 2019-05-09 14:29:14
你只能指定一组脚本.
"background": {
"persistent": false,
"scripts": [ "jquery111.js"]
}..。或者一个页面,然后该页可以引用页面所需的脚本:
"background": {
"persistent": false,
"page": "background.html"
}理论上,您的background.html页面只能是一个需要脚本的列表。
<script src="jquery111.js"></script>如果尝试同时指定这两种情况,则扩展将不会加载:
background.page和background.scripts属性不能同时使用。无法加载清单。
https://stackoverflow.com/questions/24978473
复制相似问题