1.)在组建卸载的时候保存滚动条
componentWillUnmount(){
// 记录滚动条
const distance = this.getScrollTop();
this.props.scrollSiteActions.update(distance) //保存到redux
}
2.)在Dom第一次渲染后
componentDidMount(){
const callback= ()=>{
let site = this.props.scrollSite;
if (site != '') {
this.to(site)
}
}
setTimeout(callback,1); //回到滚动条 需要异步延迟
}