mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): access resolved scrollBehaviorType
(#22264)
This commit is contained in:
parent
9742bffac2
commit
429d3656e9
@ -2,6 +2,7 @@ import type { RouteLocationNormalized, RouterScrollBehavior } from '#vue-router'
|
||||
import { nextTick } from 'vue'
|
||||
import type { RouterConfig } from 'nuxt/schema'
|
||||
import { useNuxtApp } from '#app/nuxt'
|
||||
import { useRouter } from '#app/composables/router'
|
||||
// @ts-expect-error virtual file
|
||||
import { appPageTransition as defaultPageTransition } from '#build/nuxt.config.mjs'
|
||||
|
||||
@ -12,7 +13,8 @@ type ScrollPosition = Awaited<ReturnType<RouterScrollBehavior>>
|
||||
export default <RouterConfig> {
|
||||
scrollBehavior (to, from, savedPosition) {
|
||||
const nuxtApp = useNuxtApp()
|
||||
const behavior = this.scrollBehaviorType ?? 'auto'
|
||||
// @ts-expect-error untyped, nuxt-injected option
|
||||
const behavior = useRouter().options?.scrollBehaviorType ?? 'auto'
|
||||
|
||||
// By default when the returned position is falsy or an empty object, vue-router will retain the current scroll position
|
||||
// savedPosition is only available for popstate navigations (back button)
|
||||
|
Loading…
Reference in New Issue
Block a user