获取地址栏参数

      function queryParam(name, url = location.search) {
        let res = {}
        const keys = url.match(/[w]+(?=[=]{1})/g)
        const val = url.match(/(?:[=]{1})[w]*/g)
        keys.forEach((item, index) => {
          res[item] = val[index].replace('=', '')
        })
        return res[name] || null
      }
原文地址:https://www.cnblogs.com/liea/p/12492104.html