create-selector-query-onScroll.uvue 813 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<template>
  <scroll-view @scroll="onScroll" style="flex: 1;">
    <view v-for="i in 60" class="content-item">
      <text class="text">item-{{i}}</text>
    </view>
  </scroll-view>
</template>

<script>
  export default {
    data() {
      return {
        count: 0,
        ret: true
      }
    },
    onLoad() {

    },
    methods: {
      onScroll() {
        this.count++
        console.log("scroll: ", this.count)
        uni.createSelectorQuery()
          .in(this)
          .selectAll('content-item')
          .boundingClientRect()
          .exec((result) => {
            this.count--
          })
        console.log("scroll: ", this.count)

        if (this.count > 0) {
          this.ret = false
        }
      }
    }
  }
</script>

<style>

</style>