[Vuejs]-Nuxtjs $refs scrollTop not move top

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.

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 });
    }
  }

Leave a comment