0👍
Your page needs to have enough content for scrollTop
or scrollIntoView
to be able to work.
Most likely there’s nothing after the div, so the page cannot scroll.
Add some more content and you’ll see the content move.
- [Vuejs]-How to open a vue component in new tab without page load by vue router?
- [Vuejs]-Problem in Vue Express with displaying image
0👍
ok, i found out it is not vue/nuxt problem. the container got auto scroll properties. so that is why it is not working.thanks
0👍
This worked for me in any component without ref (but it only scrolls to top), smooth scrolling is default behavior
<button @click=scrollToTop()>Jump to top of page
methods: {
scrollToTop() {
window.scrollTo({ top: 0 });
}
}
Source:stackexchange.com