Antd react router navigation changes to the appropriate page option as the page jumps to the menu bar

use antd component react frame single page router my page column jumps want to achieve the left menu bar navigation index also changes to the corresponding page options, how do you achieve this function! Just give me some ideas picture description

Mar.03,2021

judge the selected key based on url

render() {
    const pathName = hashHistory.getCurrentLocation().pathname;
    return (
        <Menu selectedKeys={[pathName]} >
        ...
        </Menu>
    );
}

if you use the Menu component of antd, you already have this feature.


have brothers solved it? Share!


directly gives you a Demo. DvaInitial , and the menu is implemented using antd's menu.


there is an idea that, if it is antd, your menu bar Sider component should have a method to set selectedKeys according to the time you click, so when you jump or move forward or backward within the page, you can call the method to set selectedKeys in the componentWillReceiveProps status method to make the menu highlight correspond to the jump on the page

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3120b-2bd63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3120b-2bd63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?