import { Switch, Prompt } from"react-router-dom"
Prompt组件:
<Prompt when={true} message="提示消息">when为boolean值,true为会提示消息,false则不会提示
Redirect组件:
<Redirect path="/home" to="/about">或<Route path="/home" render={() => <Redirect to="/about">}>
match对象:匹配路由参数的对象,有属性url、path、isExact属性

Switch组件:
只渲染所匹配到的第一个
本文介绍了React中用于导航和路由管理的几个关键组件,包括Prompt、Redirect及Switch等,并解释了它们的基本用法和属性设置。
1671

被折叠的 条评论
为什么被折叠?



