错误:Components.utils未定义-Firefox加载项
Error: Components.utils undefined - Firefox Add-on
我正在开发一个Firefox插件(使用插件SDK),我需要使用cookie。为了做到这一点,我应该导入"Services.jsm"模块。
我遵循了MDN的指示,MDN建议使用
Components.utils.import("resource://gre/modules/Services.jsm");
我也试过:
Components.utils["import"]("resource://gre/modules/Services.jsm");
当使用两者时,我得到:
- _errorType = TypeError
- message = Components.utils is undefined
有人知道如何解决这个问题吗?
参考文献:Components.utils.import
在SDK上使用Addon时,必须通过以下方式导入:
const { Cu } = require("chrome");
let Services = Cu.import("resource://gre/modules/Services.jsm");
请参阅https://blog.mozilla.org/addons/2012/02/16/using-jsm-modules-in-the-sdk/了解更多详细信息。
相关文章:
- 列出IE加载项的Javascript
- 在OfficeJS Office加载项中标识活动的Office应用程序
- Office加载项don't与“;asp:”;
- 使用Microsoft Office.js加载项进行自动身份验证
- 在加载之前从内容脚本向加载项发出消息
- Firefox加载项:从选项卡获取文档
- Outlook加载项使用Javascript将附件保存到磁盘
- 使用Firefox加载项修改网站
- 用一个加载项绘制图像阵列
- Firefox加载项验证提供了document.write&innerHTML错误
- Mozilla Firefox加载项将不会启动
- 无法通过Microsoft Office JavaScript加载项对Trello进行身份验证
- Firefox加载底部屏幕从未停止
- Excel 2016 加载项如何更改列格式
- 如何使用 Office 365 加载项(以前称为 Office 相关应用程序)将功能区和用户可定义的函数添加到 Exce
- Firefox加载项从后台/内容脚本访问弹出脚本
- 尝试使用自定义Firefox扩展/加载项中的xpath和javascript引用页面中的文本时失败
- 错误:Components.utils未定义-Firefox加载项
- firefox加载项中的contentScriptListener无法启动相应的文件
- Firefox加载项按钮代码不工作-Javascript