美文网首页
split方式获取query参数

split方式获取query参数

作者: 叶小七的真命天子 | 来源:发表于2020-05-21 13:41 被阅读0次
const gerQueryParams =() => {
  const searchStr = window.location.search.substring(1)
  return searchStr.split('&').reduce((params, cur) => {
    const [k, v] = cur.split('=').map(decodeURIComponent)
    params[k] = v
    return params
  }, {})
}

相关文章

网友评论

      本文标题:split方式获取query参数

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