Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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 具有多级动态路由的React路由器_Reactjs_React Router V4 - Fatal编程技术网

Reactjs 具有多级动态路由的React路由器

Reactjs 具有多级动态路由的React路由器,reactjs,react-router-v4,Reactjs,React Router V4,我正在从事一个需要多层次动态路由的项目。为了了解动态路由的概念,我在React Router文档中使用了递归路由示例。然而,这(显然)显示了前面的路线,这不是我需要的。我只对显示最终路线感兴趣,但我没有足够的悟性或经验来弄清楚如何修改它以使其工作 我已经创建了一个codesandbox来显示工作的递归路由 我正在寻找的功能是,如果用户导航到urldomain.com/opt3/ch2-opt2/ch3-opt3,其中/opt3/ch2-opt2/ch3-opt3/都是动态的,他们将只看到ch3-

我正在从事一个需要多层次动态路由的项目。为了了解动态路由的概念,我在React Router文档中使用了递归路由示例。然而,这(显然)显示了前面的路线,这不是我需要的。我只对显示最终路线感兴趣,但我没有足够的悟性或经验来弄清楚如何修改它以使其工作

我已经创建了一个codesandbox来显示工作的递归路由

我正在寻找的功能是,如果用户导航到urldomain.com/opt3/ch2-opt2/ch3-opt3,其中/opt3/ch2-opt2/ch3-opt3/都是动态的,他们将只看到ch3-opt3的路径。递归示例的问题显然是,它显示了opt3ch2-opt2ch3-opt3的路由,而不仅仅是ch3-opt3的路由


提前感谢您的帮助

我想出来了。React路由器v4允许多个参数。因此,domain.com/:id1/:id2/:id3/:id4的URL结构产生match.id1、match.id2、match.id3和match.id4