From 0bcc34efa7353b9cbcffee82bf88678a60601f66 Mon Sep 17 00:00:00 2001 From: zrh122 <1229550935@qq.com> Date: Tue, 22 Jan 2019 16:24:27 +0800 Subject: [PATCH] fix(router-view): add condition to see whether the tree is inactive close #2552 --- src/components/view.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/view.js b/src/components/view.js index f6183a0f4..a3c8a0319 100644 --- a/src/components/view.js +++ b/src/components/view.js @@ -26,11 +26,14 @@ export default { let depth = 0 let inactive = false while (parent && parent._routerRoot !== parent) { - if (parent.$vnode && parent.$vnode.data.routerView) { - depth++ - } - if (parent._inactive) { - inactive = true + const vnodeData = parent.$vnode && parent.$vnode.data + if (vnodeData) { + if (vnodeData.routerView) { + depth++ + } + if (vnodeData.keepAlive && parent._inactive) { + inactive = true + } } parent = parent.$parent }