原理:利用react-activation插件实现页面位置的保持,然后使用redux进行数据的更新
一、安装react-activation插件
怎么使用react-activation可以参考:
https://github.com/CJY0208/react-activation/blob/master/README_CN.md
二、列表页使用组件
页面内引入 import KeepAlive, { withAliveScope } from ‘react-activation’;
注意KeepAlive支持的是内部滚动,所以列表页用flex布局比较好
<KeepAlive name='keppAlive'>
<>
列表组件
<>
</KeepAlive>
如何返回上一页页面我们想清除缓存则使用
const { dropScope } = this.props;
dropScope('keppAlive')
withAliveScope(Dashboard)