diff --git a/lib/app/client.js b/lib/app/client.js index 759fdb58b2..d5c10ba24b 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -196,6 +196,12 @@ function callMiddleware (Components, context, layout) { async function render (to, from, next) { if (this._pathChanged === false && this._queryChanged === false) return next() + // Handle first render on SPA mode + if (to === from) _lastPaths = [] + else { + const fromMatches = [] + _lastPaths = getMatchedComponents(from, fromMatches).map((Component, i) => compile(from.matched[fromMatches[i]].path)(from.params)) + } // nextCalled is true when redirected let nextCalled = false @@ -204,8 +210,6 @@ async function render (to, from, next) { <% if(loading) { %>if (from.path !== path.path && this.$loading.pause) this.$loading.pause()<% } %> if (nextCalled) return nextCalled = true - const matches = [] - _lastPaths = getMatchedComponents(from, matches).map((Component, i) => compile(from.matched[matches[i]].path)(from.params)) next(path) } @@ -333,7 +337,6 @@ async function render (to, from, next) { // If not redirected if (!nextCalled) { <% if (loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> - _lastPaths = Components.map((Component, i) => compile(to.matched[matches[i]].path)(to.params)) next() }