dawnven
V2EX  ›  React

react 路由怎么实现,一个页面没有对与菜单,我刷新这个页面,它默认高亮这个页面对应的上一级菜单

  •  
  •   dawnven ·
    PRO
    · Jan 29, 2019 · 2054 views
    This topic created in 2684 days ago, the information mentioned may be changed or developed.

    存在页面对应菜单,我刷新页面怎么实现高亮对应菜单,之前试过刷新后总是没高亮。

    还有一点 react 路由怎么实现,一个页面没有对与菜单,我刷新这个页面,它默认高亮这个页面对应的上一级菜单

    有没有相关文章,求分享

    2 replies    2019-04-23 06:24:17 +08:00
    ghostheaven
        1
    ghostheaven  
       Jan 31, 2019 via Android
    当前路由跟菜单项做匹配,匹配的项目高亮。要么就是每次切换路由前记录高亮的菜单项。
    kwrush
        2
    kwrush  
       Apr 23, 2019
    withRouter 获取当前路由,然后做匹配?
    https://reacttraining.com/react-router/core/api/withRouter
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2814 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 01:24 · PVG 09:24 · LAX 18:24 · JFK 21:24
    ♥ Do have faith in what you're doing.