Skip to content

Commit 1c4e103

Browse files
author
chenghao
committed
更新面包屑首页菜单跳转问题
1 parent ef375a3 commit 1c4e103

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/SiderCustom.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ class SiderCustom extends Component {
1515
selectedKey: ''
1616
};
1717
componentDidMount() {
18-
const _path = this.props.path;
19-
this.setState({
20-
openKey: _path.substr(0, _path.lastIndexOf('/')),
21-
selectedKey: _path
22-
});
18+
this.setMenuOpen(this.props);
2319
}
2420
componentWillReceiveProps(nextProps) {
2521
console.log(nextProps);
2622
this.onCollapse(nextProps.collapsed);
23+
this.setMenuOpen(nextProps)
2724
}
25+
setMenuOpen = props => {
26+
const {path} = props;
27+
this.setState({
28+
openKey: path.substr(0, path.lastIndexOf('/')),
29+
selectedKey: path
30+
});
31+
};
2832
onCollapse = (collapsed) => {
2933
console.log(collapsed);
3034
this.setState({

0 commit comments

Comments
 (0)