Skip to content

Commit

Permalink
fix(router-view): register instance in init hook
Browse files Browse the repository at this point in the history
  • Loading branch information
zrh122 committed Mar 30, 2019
1 parent 7ff4de4 commit 7f55411
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ export default {
matched.instances[name] = vnode.componentInstance
}

// register instance in init hook
// in case kept-alive component be actived when routes changed
data.hook.init = (vnode) => {
if (vnode.data.keepAlive &&
vnode.componentInstance &&
vnode.componentInstance !== matched.instances[name]
) {
matched.instances[name] = vnode.componentInstance
}
}

// resolve props
let propsToPass = data.props = resolveProps(route, matched.props && matched.props[name])
if (propsToPass) {
Expand Down

0 comments on commit 7f55411

Please sign in to comment.