react-activation
react-activation copied to clipboard
Qiankun技术栈,子应用切换,手动调用clear,无法清除所有cache?
const aliveController = useAliveController()
window.aliveController = aliveController
const initQianKun = () => {
renderWithQiankun({
// 文档 https://qiankun.umijs.org/zh/guide/getting-started#
mount(props: any) {
console.log('QMS子应用开始挂载......')
const { container, namespace } = props
renderApp(container, namespace)
// 监听主应用传值
props.onGlobalStateChange((res: any) => {
console.log(res.count)
})
},
bootstrap() {},
update() {},
unmount() {
console.log('QMS子应用已经卸载......')
window.aliveController.clear()
console.log(window.aliveController.getCachingNodes())
}
})
}
// 判断当前应用是否在主应用中
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQianKun() : renderApp()
window.aliveController.clear()
console.log(window.aliveController.getCachingNodes())
清除后,打印还有当前子应用最后停留的页面缓存cache???
@CJY0208 子应用卸载了,但是console.log的缓存就是切换前子应用最后停留的页面,clear并没有清除掉所有缓存。如何解决呢?
setTimeout 延时清楚和打印命令试试,可能子应用还没有完全卸载,处于激活状态的缓存是无法清楚的
@CJY0208 对于乾坤,有没有办法,强制卸载处于激活状态的缓存
@CJY0208 因为我切换到其他子应用的时候,当前页面肯定属于激活状态。
是基座的 KeepAlive 还是子应用的 KeepAlive? 如果是子应用的 KeepAlive,就算缓存没及时清,qiankun 依然会移除整个子应用,在这之后子应用内的缓存会被一同清理
如果是基座的 KeepAlive,想要清除子应用的缓存,那就不要对子应用做 KeepAlive 就好