Skip to content

Commit

Permalink
fix(RouterAlive): 解决由于 Vue v2.6.13 版本 KeepAlive 精简了缓存组件的数据,导致移除缓存失败
Browse files Browse the repository at this point in the history
#121

相关提交:vuejs/vue@e7baaa1
  • Loading branch information
bhuh12 committed Jun 3, 2021
1 parent d222d07 commit 93f8418
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/components/RouterAlive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,10 @@ export default {
// 清理 keepAlive 缓存记录
Object.entries(cache).find(([id, item]) => {
if (item && item.data.key === key) {
const vm = item?.componentInstance
if (vm?.$vnode?.data?.key === key) {
// 销毁组件实例
item.componentInstance && item.componentInstance.$destroy()
vm.$destroy()
cache[id] = null
remove(keys, id)
Expand Down

0 comments on commit 93f8418

Please sign in to comment.