反应路由器4-动态参数匹配的多路径

时间:2018-07-24 03:05:57

标签: reactjs react-router

我已经尝试过使用正则表达式路径匹配的React Router 4,但无法正常工作。我以为我可以做这样的事情:

$ charinfo 'tͭeͤxͯtͭ oͦn tͭoͦp oͦf hͪeͤrͬeͤ' U+0074 LATIN SMALL LETTER T [Ll] U+036D COMBINING LATIN SMALL LETTER T [Mn] U+0065 LATIN SMALL LETTER E [Ll] U+0364 COMBINING LATIN SMALL LETTER E [Mn] U+0078 LATIN SMALL LETTER X [Ll] U+036F COMBINING LATIN SMALL LETTER X [Mn] U+0074 LATIN SMALL LETTER T [Ll] U+036D COMBINING LATIN SMALL LETTER T [Mn] U+0020 SPACE [Zs] U+006F LATIN SMALL LETTER O [Ll] U+0366 COMBINING LATIN SMALL LETTER O [Mn] U+006E LATIN SMALL LETTER N [Ll] U+0020 SPACE [Zs] U+0074 LATIN SMALL LETTER T [Ll] U+036D COMBINING LATIN SMALL LETTER T [Mn] U+006F LATIN SMALL LETTER O [Ll] U+0366 COMBINING LATIN SMALL LETTER O [Mn] U+0070 LATIN SMALL LETTER P [Ll] U+0020 SPACE [Zs] U+006F LATIN SMALL LETTER O [Ll] U+0366 COMBINING LATIN SMALL LETTER O [Mn] U+0066 LATIN SMALL LETTER F [Ll] U+0020 SPACE [Zs] U+0068 LATIN SMALL LETTER H [Ll] U+036A COMBINING LATIN SMALL LETTER H [Mn] U+0065 LATIN SMALL LETTER E [Ll] U+0364 COMBINING LATIN SMALL LETTER E [Mn] U+0072 LATIN SMALL LETTER R [Ll] U+036C COMBINING LATIN SMALL LETTER R [Mn] U+0065 LATIN SMALL LETTER E [Ll] U+0364 COMBINING LATIN SMALL LETTER E [Mn]

基本上,将默认路径<Route path='/(|blogs/:id)/' render={(props) => (<BlogCategory {...props} />)}/>与以下路径:/匹配,并使用相同的 BlogCategory 组件进行渲染,在该组件中,我将提取/blogs/:id使用:id

我已经找到了其他方法来匹配上方的2条路径,但它们不太优雅。因此,问题是,如何将同一个组件与正则表达式匹配的多个路径一起使用,其中某些路径可能具有动态参数?

0 个答案:

没有答案