react-router+antD/ How to highlight a menu item when press back/forward button?

后端 未结 6 2246
[愿得一人]
[愿得一人] 2021-02-12 17:54

I create a menu and want to highlight the item which i choose,and i did it. But when i press back/forward button,the menu item don\'t highlight. What should i do?

I ha

6条回答
  •  广开言路
    2021-02-12 18:12

    Intercepts the current URL and then set selectedKeys(Note that it is not defaultSelectedKeys).

    componentWillMount(){
            hashHistory.listen((event)=>{
                pathname = event.pathname.split("/");
                if(pathname != null){
                    this.setState({
                        test:pathname[1]
                    });
                }
            });
        }
    

提交回复
热议问题