Reactjs 反应路由器Dom子路由

Reactjs 反应路由器Dom子路由,reactjs,react-router-dom,Reactjs,React Router Dom,我正在创建一个小的react应用程序,在其中我在根组件上放置了如下路由 return ( <div> <Header /> <Route exact path='/' component={Homepage}/> <Route exact path='/shop' component={Shop}/> <Route exact path='/shop/:category'

我正在创建一个小的react应用程序,在其中我在根组件上放置了如下路由

return (
    <div>
        <Header />
        <Route exact path='/' component={Homepage}/>
        <Route exact path='/shop' component={Shop}/>
        <Route exact path='/shop/:category' component={Category}/>
    </div>
)

当我这样做时,类别组件不会渲染,但当我将路由放置在应用程序组件上时,它会渲染。我已经记录了match对象,这很好,因为即使是使用相同对象的集合页面也在渲染,但无论出于何种原因,第二个路由都不会渲染

精确
属性仅当当前位置路径与提供的
路径
属性相同时才渲染路由

当当前位置路径位于
/shop/:category
中时,它将不会呈现
,因为
/shop/:category!==/商店

尝试删除内部包含子路由的组件的
exact
属性

      <div>
        <Header />
        <Route exact path='/' component={Homepage}/>
        <Route path='/shop' component={Shop}/>
      </div>

      <div>
        <Header />
        <Route exact path='/' component={Homepage}/>
        <Route path='/shop' component={Shop}/>
      </div>