mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
router: Don't call middleware and asyncData on query changes
This commit is contained in:
parent
2c8023bde9
commit
6e44afedb8
@ -97,13 +97,11 @@ function mapTransitions(Components, to, from) {
|
||||
}
|
||||
|
||||
async function loadAsyncComponents (to, from, next) {
|
||||
// Check if route hash changed (this._hashChanged)
|
||||
const fromPath = from.fullPath.split('#')[0]
|
||||
const toPath = to.fullPath.split('#')[0]
|
||||
this._hashChanged = fromPath === toPath
|
||||
// Check if route path changed (this._pathChanged)
|
||||
this._pathChanged = from.path !== to.path
|
||||
|
||||
<% if (loading) { %>
|
||||
if (!this._hashChanged && this.$loading.start) {
|
||||
if (this._pathChanged && this.$loading.start) {
|
||||
this.$loading.start()
|
||||
}
|
||||
<% } %>
|
||||
@ -173,7 +171,7 @@ function callMiddleware (Components, context, layout) {
|
||||
}
|
||||
|
||||
async function render (to, from, next) {
|
||||
if (this._hashChanged) return next()
|
||||
if (this._pathChanged === false) return next()
|
||||
|
||||
// nextCalled is true when redirected
|
||||
let nextCalled = false
|
||||
@ -258,7 +256,7 @@ async function render (to, from, next) {
|
||||
await Promise.all(Components.map((Component, i) => {
|
||||
// Check if only children route changed
|
||||
Component._path = compile(to.matched[i].path)(to.params)
|
||||
if (!this._hadError && this._isMounted && Component._path === _lastPaths[i] && (i + 1) !== Components.length) {
|
||||
if (!this._hadError && this._isMounted && Component._path === _lastPaths[i]) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
@ -347,7 +345,7 @@ function showNextPage(to) {
|
||||
// When navigating on a different route but the same component is used, Vue.js
|
||||
// Will not update the instance data, so we have to update $data ourselves
|
||||
function fixPrepatch (to, from) {
|
||||
if (this._hashChanged) return
|
||||
if (this._pathChanged === false) return
|
||||
|
||||
Vue.nextTick(() => {
|
||||
const instances = getChangedComponentsInstances(to, from)
|
||||
|
Loading…
Reference in New Issue
Block a user