mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +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) {
|
||||
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)
|
||||
|
@ -43,25 +43,12 @@ export default {
|
||||
|
||||
const [matchedRoute] = this.$route.matched
|
||||
const Component = matchedRoute && matchedRoute.components.default
|
||||
|
||||
if (Component && Component.options) {
|
||||
const { key, watchQuery } = Component.options
|
||||
const { options } = Component
|
||||
|
||||
if (key) {
|
||||
return (typeof key === 'function' ? key(this.$route) : 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
|
||||
if (options.key) {
|
||||
return (typeof options.key === 'function' ? options.key(this.$route) : options.key)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user