修复项目详情页回退到首页,页面不刷新问题
This commit is contained in:
parent
be8f926cbd
commit
fd2df1505b
12
src/App.js
12
src/App.js
|
|
@ -193,10 +193,16 @@ class App extends Component {
|
|||
this.props.history.push(`/${login}`);
|
||||
}
|
||||
// 添加路由监听,决定组织还是个人
|
||||
this.unlisten = this.props.history.listen((location,history) => {
|
||||
// if(login && )
|
||||
this.unlisten = this.props.history.listen((location,action) => {
|
||||
let newPathname = location.pathname.split('/')[1];
|
||||
if (this.state.pathName !== newPathname) {
|
||||
if (location.pathname === '/' && action === 'POP') { // 浏览器回退/前进
|
||||
this.setState({
|
||||
pathName: null,
|
||||
pathType: null
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (newPathname !== this.state.pathName) {
|
||||
newPathname && this.getPathnameType(newPathname);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue