right now doing this
`import { Route } from "vue-router";
const scrollBehavior = (to: Route, from: Route, savedPosition: any) => {
console.log(savedPosition);
console.log(to);
console.log(from);
return { x: 0, y: 0 };
};
export default scrollBehavior;`
has no affect. (console.log shows nothing) whereas changing it to .js works fine.
im trying to push to a page (kept alive) with the last saved position.
@e-lobo Unfortunately there is no support for TypeScript for this feature, you may want to try with nuxt-ts, but I think it's overall tied to Nuxt internals which looks for a .js file.
@kevinmarrec yes i am using it with nuxt-ts.. works with .js only
@e-lobo Yeah so I was right, there's no currently workaround for now, I'm myself using a .js version in my Nuxt TypeScript projects. I will reach Nuxt Core Team to see if we can enable TypeScript support for this file for Nuxt 3.
I have this in one of my projects. It is a vue-cli project so not sure if you can use it for nuxt but here you go...
import { RouterScrollBehavior } from 'vue-router';
const scrollBehavior: RouterScrollBehavior = (to, from, savedPosition) => {
// Different return options here
}
Most helpful comment
@e-lobo Yeah so I was right, there's no currently workaround for now, I'm myself using a
.jsversion in my Nuxt TypeScript projects. I will reach Nuxt Core Team to see if we can enable TypeScript support for this file for Nuxt 3.