no message

This commit is contained in:
chenxuan
2024-04-24 17:47:34 +08:00
parent 6df94d8ac7
commit 8d0dc785c5
2 changed files with 24 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import {
useLocation,
useNavigate,
useParams
} from "react-router-dom";
// useNavigate 用来跳转用的 函数组件使用 useLocation接收参数用 useParams接收参数
function withRouter(Component) {
function ComponentWithRouterProp(props) {
let location = useLocation();
let navigate = useNavigate();
let params = useParams();
return (
<Component
{...props}
router={{ location, navigate, params }}
/>
);
}
return ComponentWithRouterProp;
}
export default withRouter;
+2
View File
@@ -22,4 +22,6 @@
14、push与replace
15、witchRoute 使一般组件拥有路由组件的属性,返回值是一个新组件
16、编程式路由
this.props.push()
this.props.replace()