S
S
SM_ST2020-12-16 22:08:20
Vue.js
SM_ST, 2020-12-16 22:08:20

Why doesn't nextTick work?

Tell me why nextTick does not work, I move the scroll, but in alert it gives a value before moving

prevBanner () {
      const $scroll = this.$refs.bannerScroll.scrollLeft
      this.$refs.bannerScroll.scrollTo({
        left: $scroll - 750,
        behavior: 'smooth'
      })
      this.$nextTick(() => {
        if (this.$refs.bannerScroll.scrollLeft === 0) {
          this.isVisiblePrev = false
        }
        alert(this.$refs.bannerScroll.scrollLeft)
        this.isVisibleNext = true
      })
    },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-12-16
@SM_ST

Well, because smooth. $nextTick- this is not some abstract "when it's over", it's literally the next vue tick, which will come in a couple of milliseconds. smoothBy then it will just start spinning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question