fix(vue-app): reuse page component with watchQuery (#5757)

This commit is contained in:
Jun 2019-05-20 03:57:20 +09:00 committed by Pooya Parsa
parent 75f5d4fded
commit 7084b3a126
2 changed files with 9 additions and 17 deletions

View File

@ -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)

View File

@ -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)
}
}