文档 是这样的 

function useQuery() {
  return new URLSearchParams(useLocation().search);
}

------使用

function demo (){
  const history = useHistory();
  history.get('name')
}

-------------------自己写--------------------------

import { useLocation} from 'react-router-dom';
const qs = require('query-string');

export function useQuery() {
  const { search } = useLocation();
  return qs.parse(search);
}
 
------使用
const query = useQuery();
console.log(query)  // {id: "1222", name: "zhansan"}
 


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-10-07
猜你喜欢
  • 2022-12-23
  • 2021-05-13
  • 2021-12-17
  • 2021-11-05
  • 2022-12-23
  • 2021-10-06
相关资源
相似解决方案