【问题标题】:reactjs url changes on navlink but view doesn't changenavlink上的reactjs url更改但视图没有更改
【发布时间】:2018-11-14 15:10:04
【问题描述】:
<Route path="/dashboard/:id/:screenId/:userId" component={this.Routing}/>

这里 :id 是 Profile,:screenId 是 timelinefriendssubjects 取决于特定的标签我点击 :userId 是一个特定的 tokenId

因此,例如,url 看起来像

dashboard/profile/timeline/abc123 OR dashboard/profile/friends/abc123 etc.

但无论 :id 之后是什么,只要我单击选项卡,URL 就会发生变化,但视图不会改变。我必须重新加载页面才能获得视图。任何帮助将不胜感激

【问题讨论】:

    标签: javascript css html reactjs react-router


    【解决方案1】:

    我不知道t get why you use three URL parameters. I get you need URL parameter for tokens but for rendering different components you dont 需要 URL 参数。

    <Route path="/dashboard/profile/timeline/:token" component={...}/>
    <Route path="/dashboard/profile/friends/:token" component={...}/>
    <Route path="/dashboard/profile/subjects/:token" component={...}/>
    

    但对于您的用例,您可能需要三个不同的 URL 参数。所以也许更多的解释?

    【讨论】:

      猜你喜欢
      • 2021-08-10
      • 1970-01-01
      • 2018-02-20
      • 2017-04-14
      • 2017-01-29
      • 1970-01-01
      • 2021-01-13
      • 2014-05-31
      • 1970-01-01
      相关资源
      最近更新 更多