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.

14 lines
347 B

2 years ago
  1. // 使用 params 传参。还需要在 App.js 的传参路径 path 添加 /:id
  2. // 例如:<Route path="about/:id" element={<About/>}></Route>
  3. import { useParams } from 'react-router-dom'
  4. function About () {
  5. const params = useParams()
  6. return (
  7. <div>About得到的参数 id 值为 {params.id}</div>
  8. )
  9. }
  10. export default About