Geolocation MDN加载项SDK地理位置错误:xpcwrapednative“u NoHelper-”quot;NS“错误XPC坏IID”;

Geolocation MDN加载项SDK地理位置错误:xpcwrapednative“u NoHelper-”quot;NS“错误XPC坏IID”;,geolocation,firefox-addon,firefox-addon-sdk,Geolocation,Firefox Addon,Firefox Addon Sdk,如果其他任何人在构建带有地理定位功能的mozilla插件时,在尝试地理定位用户时遇到了XPCWrappedNative\u NoHelper-“NS\u ERROR\u XPC\u BAD\u IID”问题,我有一个解决方案供您参考 当前代码(返回错误) “” 工作代码(有效) const {components, Cc, Ci} = require("chrome"); function getCurrentPosition(callback) { var xpcomGeoloca

如果其他任何人在构建带有地理定位功能的mozilla插件时,在尝试地理定位用户时遇到了XPCWrappedNative\u NoHelper-“NS\u ERROR\u XPC\u BAD\u IID”问题,我有一个解决方案供您参考


当前代码(返回错误) “”


工作代码(有效)

const {components, Cc, Ci} = require("chrome");
function getCurrentPosition(callback) {
    var xpcomGeolocation = Cc["@mozilla.org/geolocation;1"].getService(Ci.nsISupports);
    xpcomGeolocation.getCurrentPosition(callback);
}

var widget = require("sdk/widget").Widget({
    id: "whereami",
    label: "Where am I?",
    contentURL: "http://www.mozilla.org/favicon.ico",
    onClick: function() {
        getCurrentPosition(function(position) {
            console.log("latitude: ", position.coords.latitude);
            console.log("longitude: ", position.coords.longitude);
        });
    }
});