You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
347 B
15 lines
347 B
// 使用 params 传参。还需要在 App.js 的传参路径 path 添加 /:id
|
|
// 例如:<Route path="about/:id" element={<About/>}></Route>
|
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
|
function About () {
|
|
|
|
const params = useParams()
|
|
|
|
return (
|
|
<div>About得到的参数 id 值为 {params.id}</div>
|
|
)
|
|
}
|
|
|
|
export default About
|