diff --git a/lib/app/client.js b/lib/app/client.js index 6ac5cba5ae..456eac1776 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -197,9 +197,11 @@ async function render (to, from, next) { // nextCalled is true when redirected let nextCalled = false const _next = path => { - <% if(loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> + <% if(loading) { %>if (from.path === path.path && this.$loading.finish) this.$loading.finish()<% } %> + <% if(loading) { %>if (from.path !== path.path && this.$loading.pause) this.$loading.pause()<% } %> if (nextCalled) return nextCalled = true + _lastPaths = getMatchedComponents(from).map((Component, i) => compile(from.matched[i].path)(from.params)) next(path) } @@ -327,12 +329,12 @@ async function render (to, from, next) { return Promise.all(promises) })) - _lastPaths = Components.map((Component, i) => compile(to.matched[i].path)(to.params)) - - <% if(loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> - // If not redirected - if (!nextCalled) next() + if (!nextCalled) { + <% if (loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> + _lastPaths = Components.map((Component, i) => compile(to.matched[i].path)(to.params)) + next() + } } catch (error) { if (!error) error = {}