Description
Version
3.3.4
Reproduction link
https://jsfiddle.net/NightNei/5bv7co0u/10/
Steps to reproduce
1) Open "Reproduction link" -> OK - beforeResolve handler is run
2) Click "foo" btn -> OK - beforeResolve handler is run
3) Click "home" btn -> OK - beforeResolve handler is run
4) Click "destroy" btn -> OK - app destroyed
5) Click "start" btn -> FAIL - app started, but beforeResolve handler isn't run
What is expected?
beforeResolve
is always run on start app
What is actually happening?
beforeResolve
isn't run on restarting app
I am a maintainer of "Isomorphic Layout Composer" - Micro-frontends library( https://github.com/namecheap/ilc ).
And we have faced the problem of remounting Vue apps - when we render the same app second time, it will ignore running of beforeHooks
.
Since on restart app history.current.matched
contains last instance of route component so this condition:
vue-router/src/history/base.js
Line 159 in dfc2892
true
and router.beforeHooks
are ignored.On Destroy app we should reset
history.current
to default value(START
).