新版v6 react-router-dom TS 泛型约束,如有错误欢迎指正
import { useParams } from 'react-router-dom'
type DetailPageParams = {
touristRouteId: string
}
export const DetailPage: React.FC = () => {
const params = useParams<DetailPageParams>()
return <h1>旅游路径详情:路径ID{params.touristRouteId}</h1>
}
React18 精讲 + 结合 TS 实战 + 热门业务开发,获取必备技能
了解课程