js 获取URL参数

in 前端JavaScript with 0 comment
const getQueryParams = (search = window.location.search) => {
  const searchParams = new URLSearchParams(search)
  const query = {}
  for (const p of searchParams) {
    const [key, value] = p
    query[key] = value
  }
  return query
}
Comments are closed.