获取地址栏参数转成对象

export const quertObject = (url) => {
  const queryString = url.split(‘?‘)[1]
  const obj = {}
  const arr = queryString.split(‘&‘)
  for (let i = 0; i < arr.length; i++) {
    const key = arr[i].split(‘=‘)[0]
    const value = arr[i].split(‘=‘)[1]
    obj[key] = value
  }
  return obj
}
export const getQueryParams = () => {
  const result = {}
  const querystring = window.location.search
  const reg = /[?&][^?&]+=[^?&]+/g
  const found = querystring.match(reg)
  if (found) {
    found.forEach((item) => {
      let temp = item.substring(1).split(‘=‘)
      let key = temp[0]
      let value = temp[1]
      result[key] = value
    })
  }
  return result
}

 

获取地址栏参数转成对象

上一篇:Windows Server 2008搭建域控制器《转载51CTO.com》


下一篇:Matlab求切线和法平面(surfnorm,jacobian)