美文网首页前端JavaScript的技术技巧交流~
location.search的正则获取url的参数记录

location.search的正则获取url的参数记录

作者: chouchou723 | 来源:发表于2018-12-05 09:40 被阅读0次

sProp是需要获取的参数

getParameter(sProp) {
                var re = new RegExp(sProp + "=([^\&]*)", "i");
                var a = re.exec(document.location.search);
                if (a == null)
                    return null;
                return a[1];
            },

相关文章

网友评论

    本文标题:location.search的正则获取url的参数记录

    本文链接:https://www.haomeiwen.com/subject/reqicqtx.html