我想添加一个文件(background.js),它是我的 firefox 扩展的后台脚本。
我使用以下代码将内容脚本添加到我的 main.js。
var panel = panels.Panel({
contentURL: self.data.url("panel.html"),
onHide: handleHide,
contentScriptFile: [self.data.url("js/jquery.js"),
self.data.url("tipsy/jquery.tipsy.js"),,
self.data.url("js/settings.js")]
});
如何将后台脚本添加到 main.js 文件。
最佳答案
只需将文件放在 lib
文件夹。
Except for scripts that interact directly with web content, all the JavaScript code you'll write or use when developing add-ons using the SDK is part of a CommonJS module.
本质上,后端脚本不共享内容脚本/普通 JS 等变量。你
export
和 require
模块之间的变量。见 adding local modules
关于firefox - 将后台脚本添加到 firefox 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27243403/