react-activation icon indicating copy to clipboard operation
react-activation copied to clipboard

多个路由指向一个文件时候,缓存是失败

Open MTTTM opened this issue 2 years ago • 1 comments

这是页面组件,所有路由都指向这个代码

<div key={props?.location?.pathname}> <keepAlive name={props?.location?.pathname}> <p>{props?.location?.pathname}</p> <Applet {...props} portletComponent={PortletComponent} /> </keepAlive> </div>

不确定是否和react-activation有关系,还望大佬,指点一二。

div的key是因为多路由指向一个文件时候需要的

我觉得上面代码应该改成这样

<div > <keepAlive name={props?.location?.pathname}> <p>{props?.location?.pathname}</p> <Applet {...props} portletComponent={PortletComponent} key={props?.location?.pathname}/> </keepAlive> </div>

调试图片: image

是有多个keeper的,就是切回路由的时候Applet里面的组件显示不对

但是tab再切回上一个tab的时候,他还是未切换前的数据

还是大佬有其他方案,求指点。。

MTTTM avatar Sep 09 '22 02:09 MTTTM

可以提供简单的用例吗?

CJY0208 avatar Sep 21 '22 05:09 CJY0208