create-selector-query-onScroll.uvue 775 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <scroll-view @scroll="onScroll" style="flex: 1;">
  3. <view v-for="i in 60" class="content-item">
  4. <text class="text">item-{{i}}</text>
  5. </view>
  6. </scroll-view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. count: 0,
  13. ret: true
  14. }
  15. },
  16. onLoad() {
  17. },
  18. methods: {
  19. onScroll() {
  20. this.count++
  21. console.log("scroll: ", this.count)
  22. uni.createSelectorQuery()
  23. .in(this)
  24. .selectAll('content-item')
  25. .boundingClientRect()
  26. .exec((result) => {
  27. this.count--
  28. })
  29. console.log("scroll: ", this.count)
  30. if (this.count > 0) {
  31. this.ret = false
  32. }
  33. }
  34. }
  35. }
  36. </script>
  37. <style>
  38. </style>