javascript模块简单写法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript模块简单写法相关的知识,希望对你有一定的参考价值。
写法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 () {}();
以上是关于javascript模块简单写法的主要内容,如果未能解决你的问题,请参考以下文章