mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 23:21:09 +00:00
fix(vue-app): reuse page component with watchQuery
(#5757)
This commit is contained in:
parent
75f5d4fded
commit
7084b3a126
@ -506,6 +506,11 @@ function fixPrepatch(to, ___) {
|
|||||||
for (const key in newData) {
|
for (const key in newData) {
|
||||||
Vue.set(instance.$data, key, newData[key])
|
Vue.set(instance.$data, key, newData[key])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure to trigger scroll event after calling scrollBehavior
|
||||||
|
window.<%= globals.nuxt %>.$nextTick(() => {
|
||||||
|
window.<%= globals.nuxt %>.$emit('triggerScroll')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
showNextPage.call(this, to)
|
showNextPage.call(this, to)
|
||||||
|
@ -43,25 +43,12 @@ export default {
|
|||||||
|
|
||||||
const [matchedRoute] = this.$route.matched
|
const [matchedRoute] = this.$route.matched
|
||||||
const Component = matchedRoute && matchedRoute.components.default
|
const Component = matchedRoute && matchedRoute.components.default
|
||||||
|
|
||||||
if (Component && Component.options) {
|
if (Component && Component.options) {
|
||||||
const { key, watchQuery } = Component.options
|
const { options } = Component
|
||||||
|
|
||||||
if (key) {
|
if (options.key) {
|
||||||
return (typeof key === 'function' ? key(this.$route) : key)
|
return (typeof options.key === 'function' ? options.key(this.$route) : options.key)
|
||||||
}
|
|
||||||
|
|
||||||
if (watchQuery) {
|
|
||||||
if (watchQuery.length) {
|
|
||||||
const pickedQuery = {}
|
|
||||||
for (const queryKey of watchQuery) {
|
|
||||||
pickedQuery[queryKey] = this.$route.query[queryKey]
|
|
||||||
}
|
|
||||||
return this.$router.resolve({
|
|
||||||
path: this.$route.path,
|
|
||||||
query: pickedQuery
|
|
||||||
}).href
|
|
||||||
}
|
|
||||||
return this.$route.fullPath
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user