//传递的页面,用link跳转并且携带参数
<Link to={
'/notice/' + tabKey
}
notice为要跳转的页面组件,tabkey=1为传递参数,用url传参可以传递允许暴露的参数。
//挂载的路由 noticeType为接收的参数
<UserRoute path="/notice/:noticeType" component={Notice} />
//接收的页面
//notice组件
1.引入RouteComponentProps
import { RouteComponentProps } from "react-router-dom";
2.定义
interface Props {
noticeType: string
}
3.通过props拿到我们想要的noticeType
const Notice: React.FC<RouteComponentProps<Props>> = (props) => {
const noticeType = props.match.params.noticeType
}