Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我意识到两者:
Components.classes["@me.org/mycomponent;1"].createInstance();
和
Components.classes["@me.org/mycomponent;1"].getService();
以相同的方式获取 xul 组件。那么,使用一个或另一个有什么区别?
getService将创建一个单例,而createInstance每次调用它时都会创建一个新实例。 getService每次都会返回相同的对象。
getService
createInstance