获取url上的参数

var aa = '?name=hss&age=13';
        function strToObj(str){
            if(typeof str === 'undefined'){
                str = location.search;
            }
            var reg = /[\?|&]+(\w+)=(\w*)/g;
            var param = {};
            do{
                var item = reg.exec(str);
                if(item !== null){
                    param[item[1]] = item[2]
                }
            }while(reg.lastIndex > 0)
            return param;
        }
        console.time()
        console.log(strToObj());
        console.timeEnd()

执行效率还是蛮高的大概在一毫秒吧

上一篇:Spring Security4源码解读探寻权限机制


下一篇:python-Celery REST API