地址栏手动更改路由(pathname),侧边栏没有匹配高亮
jiangbo2015 opened this issue · comments
jiangbo commented
内容跟着换了,侧边栏没有匹配高亮效果,还是上一个路由的高亮
jiangbo commented
componentWillMount() {
let { keys, values, entries } = Object
const pathname = this.props.location.pathname
const _current = pathname === '/' ? introduce : pathname.substr(0, 1) === '/' ? pathname.substr(1) : pathname
const hasKeys = SideMenus.filter(value => {
return value.key !== _current && value.groups
})
let findKyes = []
if (hasKeys.length > 0) {
findKyes = hasKeys.filter(value => {
for (let value of values(value.groups)) {
return value.key === _current
}
})
}
let _openKeys = []
findKyes.length > 0 ? _openKeys.push(findKyes[0].key) : _openKeys.push('introduce')
this.setState({ current: _current, openKeys: _openKeys });
}
本人是这么处理的,不太优雅