URL拦截参数//直接调用输入你要拦截的几个参数名exportfunctiongetParamFromUrl(key){if(key===undefined)returnnull;letsearch=location.search.substr(1);letmReg=newRegExp('(^|&)'+key+'=([^&]*)(&|$)');letmValue=search.match(mReg);if(mValue!=null)returnunescape(mValue[2]);returnull;}//例子letcity=getParamFromUrl('city');判断json是否为空//输入要检测的json数据,为空则返回falseexportfunctionisNullObject(model){if(typeofmodel==="object"){lethasProp=false;for(constpropinmodel){hasProp=true;break;}if(hasProp){returnfalse;}returntrue;}else{throw"modelisnotobject";}}数据类型检测//检测变量数据类型exportfunctiongetParamType(item){if(item===null)returnnull;if(item===undefined)returnundefined;returnObject.prototype.toString.call(item).slice(8,-1);}//返回StringFunctionBooleanObjectNumber获取cookie//获取document下的cookie具体参数值exportfunctiongetCookie(key){if(key===undefined){returnundefined;}letcookies=document.cookie;letmReg=newRegExp('(^|;)\\s*'+key+'=([^;]*)(;|$)');letmValue=cookies.match(mReg);letret=undefined;if(mValue!=null){ret=unescape(mValue[2]);}if(ret!==undefined){ret=ret.replace(/^\"|\'/i,'').replace(/\"|\'$/i,'');}returnret;}版本号比较一般在做APP开发的时候,需要进行一些版本控制,所以需要针对版本号为了比较,高版本或者低版本做一些特殊的逻辑处理,下面是提供版本比较的方法//输入要比较的版本号,一般传入当前版本号第一个,后面一个写的是要比较的版本号exportfunctionversionCompare(higher,lower){letsep=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'.';lethigherAry=higher.split(sep),lowerAry=lower.split(sep);letl=Math.max(higherAry.length,lowerAry.length);for(leti=0;i
