gpt4 book ai didi

javascript - 错误 : Components. utils undefined - Firefox 附加组件

转载 作者:行者123 更新时间:2023-11-30 00:19:40 26 4
gpt4 key购买 nike

我正在开发一个 Firefox 插件(使用插件 SDK),我需要使用 cookie。为此,我应该导入 "Services.jsm"模块。

我已按照 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

最佳答案

使用Addon-on SDK时,必须这样导入:

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/了解更多详情。

关于javascript - 错误 : Components. utils undefined - Firefox 附加组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33657570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com