[Vuejs]-How do a do a scroll in to view for a newly added list item in vueJS

-1👍

I solve my problem like this

I gave my unordered list an id="taskListul"

and in methods I added a function:

  scrollToEndOfTask() {
      const taskScroll = this.$el.querySelector("#taskListul")
      const scrollHeight = taskScroll.scrollHeight
      taskScroll.scrollTop = scrollHeight
    },

I called this function in update method of the vue instance

updated() {
    this.scrollToEndOfTask()
  },

Leave a comment