[react]searchParams转普通对象
const [param, setParam] = useSearchParams()
const params = Object.fromEntries(param.entries());
console.log(params);
如果是params的话,就是用返回一个对象,
const p = useParams()
console.log(p);
为什么是对象?难道param还能有2个字段? 还真是!
给2个占位符
{
path: "/login/:uid/:uuid",
element: <Login />
}
<button onClick={() => navigate('/login/3/6?age=18&name=小明')}>点击</button>
打印
{
"uid": "3",
"uuid": "6"
}