获取地址栏参数

Posted on 2019-09-12 10:40  勤勤恳恳大猿人  阅读(107)  评论(0编辑  收藏  举报
// 工具方法,截取地址栏参数
    getQueryString (name) {
        const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        const r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    }