Google Chrome扩展程序中有多个后台脚本吗? [英] Multiple background scripts in a Google Chrome extension?
问题描述
我的任务是创建Google Chrome扩展程序.到目前为止,一切正常.但是,我希望能够使用多个后台脚本(我的意思是"background":{"scripts":["background.js"]},
(如果我在说的不清楚),而不是创建多个扩展名.这可能吗?
I've been tasked with creating a Google Chrome extension. So far, everything works fine. However, I would like to be able to use multiple background scripts (what I mean is
"background" : {"scripts" : ["background.js"]},
if what I'm talking about is unclear) rather than creating multiple extensions. Is this possible?
此致
推荐答案
扩展系统将生成一个后台页面,其中包括scripts属性中列出的每个文件.
A background page will be generated by the extension system that includes each of the files listed in the scripts property.
是的,它应该可以工作.只需声明多个脚本:
So yes, it should work. Simply declare multiple scripts:
...
"background": {
"scripts": [
"background.js",
"backgroundone.js",
"backgroundtwo.js"
]
},
...
所有这些脚本都可以像加载到同一页面中一样工作.它们都将共享相同的上下文.
All of these scripts would work as if loaded into the same page; they will all share the same context.
这篇关于Google Chrome扩展程序中有多个后台脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!