js获取地址栏参数

js获取地址栏参数

js获取地址栏参数:

getParam(name) {
      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
    }

 URLSearchParams

getParam(name){
    var obj = new URLSearchParams(window.location.search);
    return obj.get(name);
}

URLSearchParams  其他方法  参考  https://www.cnblogs.com/zshno1/p/15993017.html

posted on 2019-11-20 14:56  梦幻飞雪  阅读(194)  评论(0)    收藏  举报