nuxt: import router from '~router' stopped working
Hello. I had a fix for scrolling to top behavior when page transition, but with latest Nuxt releases it stoped working. It was a plugin:
import router from '~router'
router.afterEach((to, from) => {
setTimeout(() => {
if (document) document.body.scrollTop = 0
}, 515)
})
But now this import router from '~router' gives me an error.
Any tips how to fix it? How to access router with latest API?
<div align="right">This question is available on Nuxt.js community (#c1489)</div>About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 51
ok i found it. you need to disable the default scroll behavoir in nuxt config
https://github.com/vuejs/vue-router/pull/1758
your website isnt working in chrome canary. I think it was with
window.document.body.scrollTop = 0right?you are welcome.
With page ransition
scroll.js
nuxt.conf.js (a little different)
_animation.scss
@homerjam can you please give a link to that PR that I can know what is happening?