React路由器中的深层链接(挂钩)

问题描述 投票:0回答:1

我在应用程序中具有以下路线:

<Switch>
    <Route path="/shops/:id">
       <StoreDetails/>
    </Route>
    <Route path="/shops">
        <Stores/>
    </Route>
   <Route path="/">
      <Home/>
   </Route>
</Switch>

我如何深度链接/ shops和/ shops /:id URL ??

reactjs react-router webpack-dev-server
1个回答
2
投票

带有钩子:

import React from 'react';

export const test = props => {
 const { match } = props;
 const id = match.params.id;

 return <></>;
};
© www.soinside.com 2019 - 2024. All rights reserved.