[Vuejs]-ScrollTo invalid input in VueJs

5👍

You’ll probably need to use Vue.nextTick to wait for Vue to apply your invalid class everywhere it needs to be applied.

this.$nextTick(() => {
  let domRect = document.querySelector('.error').getBoundingClientRect();
  window.scrollTo(
    domRect.left + document.documentElement.scrollLeft,
    domRect.top + document.documentElement.scrollTop
  );
});

1👍

Just get first elements with error position:

window.scrollTo(document.querySelector('.error').offsetTop, 0);

0👍

One more way 🙂

this.$nextTick(() => {
 document.querySelector('.error').scrollIntoView({block: "center", behavior: "smooth"})
});

Leave a comment