我创建了一个简单的Javascript模块。我希望CommonJS实现,AMD实现和global()
可以使用它这是我的班级:
function Geolocation( callback ){
this._latitude = null;
this._longitude = null;
this._accuracy = null;
}
Geolocation.prototype = {
//prototype definitions in here
}
我想要实现的目标是什么?详尽的谷歌搜索没有产生任何结果
答案 0 :(得分:1)
(function (global, factory) {
if (typeof define === "function" && define.amd) define(factory); //AMD
else if (typeof module === "object") module.exports = factory(); //CommonJS
else global.Geolocation = factory(); // for example browser (global will be window object)
}(this, function () {
var Geolocation = function( callback ){
this._latitude = null;
this._longitude = null;
this._accuracy = null;
}
Geolocation.prototype = {
//prototype definitions in here
}
return Geolocation;
}));