具体表现为切换路由时,exclude 中不需要缓存的 component 无法被释放,还保存在内存中.
keep-alive 代码如下
<keep-alive :include="['shop']" :exclude="['album']">
<router-view ref="router"></router-view>
</keep-alive>
include 中的 shop 是一个需要被缓存的页面
exclude 中的 album 是一个不需要被缓存
在 shop 和 album 多次切换后, 可以发现 heap snapshot 中有大量没有释放的 vue component.
初始的 snapshot 1
多次切换路由后的 snapshot 2, 可以看到大量未释放的 component
我找到了一个相关的issue.
但是官方认为这个 bug 已经被修复了
有人遇到过这个问题吗,有什么解决办法吗?