Skip to content

Commit 529df3b

Browse files
author
taylorliu
committed
fix(keep-alive): fix keep-alive memory leak
1 parent 78c3ce0 commit 529df3b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/core/components/keep-alive.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,13 @@ export default {
120120
vnode.data.keepAlive = true
121121
}
122122
return vnode || (slot && slot[0])
123+
},
124+
updated() {
125+
const { cache } = this
126+
for(let key in cache) {
127+
if(cache[key] && cache[key].parent && (cache[key].tag != this._vnode.tag)) {
128+
cache[key].parent = null
129+
}
130+
}
123131
}
124132
}

0 commit comments

Comments
 (0)