在umi框架当中如何获取在跳转路由的时候传递的参数?

首先我们就需要知道什么是路由?

首先我们要知道umi框架分为普通路由和约定式路由。
而umi框架自身是带有路由管理的,就是在umirc.ts文件当中。
普通路由如果在没有进行传递参数的话,是直接引用umi框架自带的history,进行使用

import {
    
    history} from "umi"
let Login=()=>{
    
    
	history.push("你要进行跳转的路径")
}

然后直接在你想要实现路由跳转的按键上面使用点击事件来触发这个函数。
普通路由在进行传递参数的时候,获取传递的参数

import {
    
    history} from "umi"
const dian = (i) => {
    
    
        history.push('/Person', i)
    }

这个时候我们需要将我们想要传递的参数通过 i 传递过去,然后在跳转的路由组件当中通过

import {
    
    history} from "umi"
let Shou=props.history.location.state

来接收传递过来的参数。
而然后详细路由介绍的话,可以通过
umi路由官方文件https://v3.umijs.org/zh-CN/docs/convention-routing

猜你喜欢

转载自blog.csdn.net/qq_53509791/article/details/129871403