📜  从多个查询参数中获取数据 react - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:50.297000             🧑  作者: Mango

代码示例1
import React from 'react';
import {useLocation} from "react-router-dom";

export default function Items() {
 //Where parameter url = localhost:3000/items?name=pen&id=12
  const search = useLocation().search;
  const name = new URLSearchParams(search).get('name');  const id = new URLSearchParams(search).get('id');
  return (
    

Items page

{id}

{name}

); }