javascript模組簡單寫法

看風景就發表於2016-02-06

寫法1:

(function (wd, doc) {
   
    var mw = {};
    mw.noConflict = noConflict;
    
    var _$ = wd.$;
    wd.$ = mw;

    function noConflict() {
        wd.$ = _$;
        wd.mw = mw;
        return mw;
    }
}
)(window, document);

寫法2:

Xrm = function () {};

Xrm.Common = function () {
    var guidsAreEqual = function (guid1, guid2) {
        var isEqual;
        if (guid1 === null || guid2 === null || guid1 === undefined || guid2 === undefined) {
            isEqual = false;
        }
        else {
            isEqual = guid1.replace(/[{}]/g, "").toLowerCase() === guid2.replace(/[{}]/g, "").toLowerCase();
        }

        return isEqual;
    };

    return {
        GuidsAreEqual: guidsAreEqual
    };
}();

Xrm.Rest = function () {}();

Xrm.Soap = function () {}();

Xrm.Extension = function () {}();

 

相關文章