V
V
Valery Khizhevsky2018-04-30 09:03:57
Vue.js
Valery Khizhevsky, 2018-04-30 09:03:57

How to load data when scrolling VueJS?

Interested in calling the method when the content comes to an end, how to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lumore, 2018-04-30
@Lumore

<script>
export default {
  methods: {
    doAlert () {
      alert('Hi!')
    }
  },
  created () {
    window.addEventListener('scroll', () => {
      let body = document.getElementsByTagName('body')[0]
      if (window.scrollY > body.clientHeight) {
        this.doAlert()
      }
    })
  }
}
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question