从零打造微前端框架:实战“汽车资讯平台”项目|一起学习

逻辑流光
• 阅读 1385
'use strict';//启用严格模式
var oap={},obj_type={},core_toString=obj_type.toString,hasOwn = obj_type.hasOwnProperty;;
    var type_arr = "Boolean Number String Function Array Date RegExp Object Error".split(" ");
    for(var i in type_arr){
        obj_type[ "[object " + type_arr[i] + "]" ] = type_arr[i].toLowerCase();
    };
 
    //常用工具  判断方法 对象
    oap={
        type:function(obj){
            if ( obj == null ) {
                return String( obj );
            }
            return (typeof obj === "object" || typeof obj === "function")?(obj_type[ core_toString.call(obj) ] || "object") :typeof obj;
        },
        isStr:function(obj){
            return oap.type(obj)==="string";
        },
        isFn:function(obj){
            return oap.type(obj)==="function";
        },
        isObj:function(obj){
            return oap.type(obj) === "object";
        },
        isDate:function(obj){
            return oap.type(obj) === "date";
        },
        isEmptyObj:function(obj){
            var name;
            for ( name in obj ) {
                return false;
            }
            return true;
        },
        isNum:function(obj){
            return !isNaN( parseFloat(obj) ) && isFinite( obj );
        },
        isArr:function(obj){
            return oap.type(obj) === "array";
        },
        trim:function(obj){
            return obj.replace(/^\\s+|\\s+$/g, "");
        },
        now:function(){
            return new Date().getTime();
        },
        log:function(str){
            if(console && console.log){
                console.log(str);
            }
        }
    };
var _cookie = {
        set:function(name, value){
            var expires = (arguments.length > 2) ? arguments[2] : null,strExpires = "";
            if(expires && oap.isDate(expires)){
                strExpires =  "; expires=" + expires.toGMTString();
            }else if(expires && oap.isObj(expires)){
                var nD = oap.now(),
                    nObj = {
                        day:0,hours:0,minutes:0,seconds:0
                    },
                    dArr={
                        secondes:1000,
                        minutes:1000*60,
                        hours:1000*60*60,
                        day:1000*60*60*24
                    },
                    _val;
                nObj = oap.extend(nObj,expires);
                for(var n in expires){
                    _val = nObj[n];
                    if(oap.isNum(_val) && _val>0){
                        nD = nD + _val * dArr[n];
                    }
                }
                if(oap.isNum(nD) && nD>0){
                    nD = new Date(nD);
                    strExpires =  "; expires=" + nD.toGMTString();
                }
            }else{
                strExpires = "";
            }
 
            document.cookie = name + "=" + encodeURIComponent(value) + strExpires + ";path=/" ;
        },
        get:function(name){
            var value = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
            if (value != null) {
                return decodeURIComponent(value[2]);
            } else {
                return null;
            }
        },
        remove:function(name){
            var expires = new Date();
            expires.setTime(expires.getTime() - 1000 * 60);
            this.set(name, "", expires);
        }
    };
点赞
收藏
评论区
推荐文章
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
6个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Peter20 Peter20
4年前
mysql中like用法
like的通配符有两种%(百分号):代表零个、一个或者多个字符。\(下划线):代表一个数字或者字符。1\.name以"李"开头wherenamelike'李%'2\.name中包含"云",“云”可以在任何位置wherenamelike'%云%'3\.第二个和第三个字符是0的值wheresalarylike'\00%'4\
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
逻辑流光
逻辑流光
Lv1
我知道任何一个人少了我都不会怎样
文章
4
粉丝
0
获赞
0