Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Ant Design Pro:如何重定向路由保留查询参数_Reactjs_Ant Design Pro - Fatal编程技术网

Reactjs Ant Design Pro:如何重定向路由保留查询参数

Reactjs Ant Design Pro:如何重定向路由保留查询参数,reactjs,ant-design-pro,Reactjs,Ant Design Pro,我的用户将收到一个链接,其中包含一个密钥,该密钥对他们来说是唯一的,可以将他们指向一个步骤表单。当它们进入步骤表单时,我想在router.config中自动将它们重定向到第一步。 i、 e.他们将收到如下url: https://example.com/register/user/sales?key=1234 它们必须重定向到: https://example.com/register/user/sales/account?key=1234 但是,一旦我的用户被重定向,查询参数“?key=1

我的用户将收到一个链接,其中包含一个密钥,该密钥对他们来说是唯一的,可以将他们指向一个步骤表单。当它们进入步骤表单时,我想在router.config中自动将它们重定向到第一步。 i、 e.他们将收到如下url:

https://example.com/register/user/sales?key=1234
它们必须重定向到:

https://example.com/register/user/sales/account?key=1234
但是,一旦我的用户被重定向,查询参数“?key=1234”将丢失。 我该如何解决这个问题

我已设置router.config,如下所示:

export default [{
    path: '/register',
    component: '../layouts/RegisterLayout',
    routes: [{
        path: '/register',
        redirect: '/register/user'
    }, {
        path: '/register/user',
        name: 'user',
        component: './Register/user'
    }, {
        path: '/register/user/:division',
        name: 'user',
        component: './Register/User',
        hideChildrenInMenu: true,
        routes: [{
            path: '/register/user/:division',
            redirect: '/register/user/:division/account'
        }, {
            path: '/register/user/:division/account',
            name: 'account',
            component: './Register/User/Step1CreateAccount'
        }, {
            path: '/register/user/:division/details',
            name: 'details',
            component: './Register/User/Step2UserDetails'
        }]
  }]
}]

查询保存不能在此文件中进行,而应在呈现链接的文件中进行。我相信ant design pro在默认情况下使用的是UMI,因此您会看到如下情况:

从“umi/Link”导入链接;
导出默认值()=>{
/*正常使用*/
转到列表页
/*使用查询字符串*/
转到列表页
/*包含子组件*/
转到列表页

}
此.props.location
提取参数,并在重定向之前将其附加到下一个路由