mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 07:32:01 +00:00
fix(nuxt): scroll to top in nested routes (#21657)
This commit is contained in:
parent
de639e7ef9
commit
91ebcd7ee9
@ -57,12 +57,13 @@ function _getHashElementScrollMarginTop (selector: string): number {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function _isDifferentRoute (a: RouteLocationNormalized, b: RouteLocationNormalized): boolean {
|
function _isDifferentRoute (from: RouteLocationNormalized, to: RouteLocationNormalized): boolean {
|
||||||
const samePageComponent = a.matched[0] === b.matched[0]
|
const samePageComponent = to.matched.every((comp, index) => comp.components?.default === from.matched[index]?.components?.default)
|
||||||
|
|
||||||
if (!samePageComponent) {
|
if (!samePageComponent) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (samePageComponent && JSON.stringify(a.params) !== JSON.stringify(b.params)) {
|
if (samePageComponent && JSON.stringify(from.params) !== JSON.stringify(to.params)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user