原理:利用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)
该博客介绍利用react-activation插件实现页面位置保持,并用redux更新数据。首先需安装react-activation插件,可参考指定链接。列表页引入相关组件,KeepAlive支持内部滚动,列表页用flex布局较好,还提及返回上一页清除缓存的方法。
1007

被折叠的 条评论
为什么被折叠?



