index.vue 879 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!-- 滚动加载的list -->
  2. <template>
  3. <view class="zs-list" :style="{marginTop:mt}">
  4. <slot></slot>
  5. <zs-load-more class="more" :status="status" />
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. props: {
  11. mt: {
  12. type: String,
  13. default: '100rpx'
  14. },
  15. status: {
  16. type: String,
  17. default: 'more'
  18. },
  19. },
  20. data() {
  21. return {
  22. Observer: null, //监听相交对象
  23. }
  24. },
  25. methods: {
  26. },
  27. onReady() {
  28. this.Observer = uni.createIntersectionObserver(this)
  29. this.Observer.relativeToViewport({
  30. bottom: 0
  31. }).observe('.more', (res) => {
  32. if (this.status == 'loading') return
  33. this.$emit('load')
  34. })
  35. },
  36. beforeDestroy() {
  37. this.Observer.disconnect()
  38. }
  39. }
  40. </script>
  41. <style lang="scss" >
  42. .zs-list{
  43. // height: calc(100vh - 100rpx);
  44. // overflow: auto;
  45. // margin-top: 100rpx;
  46. .more{
  47. width: 100%;
  48. }
  49. }
  50. </style>