使用umi-plugin-keep-alive实现KeepAlive状态存储
$ npm install umi-plugin-keep-alive --save
//或者
$ yarn add umi-plugin-keep-alive
使用和vue的keepAlive类似
import { KeepAlive } from 'umi';
import HomePage from './page';
export default ({ history }) => {
return (
<KeepAlive name="homePage">
<HomePage history={history} />
</KeepAlive>
);
};
使用介绍:https://www.npmjs.com/package/umi-plugin-keep-alive
git详细文档里面有介绍如何手动刷新组件和清除组件缓存等
https://github.com/alitajs/umi-plugin-keep-alive