index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!-- 滚动加载的list -->
  2. <template>
  3. <view class="zs-list" :style="{marginTop:mt}">
  4. <slot></slot>
  5. <zs-load-more class="more" :status="status" :contentText="contentText" />
  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. contentText: {
  20. type: Object,
  21. default: ()=>{
  22. return {contentdown: "上拉显示更多",contentrefresh: "正在加载...",contentnomore: "没有更多数据了"}
  23. }
  24. },
  25. },
  26. data() {
  27. return {
  28. Observer: null, //监听相交对象
  29. }
  30. },
  31. methods: {
  32. },
  33. onReady() {
  34. this.Observer = uni.createIntersectionObserver(this)
  35. this.Observer.relativeToViewport({
  36. bottom: 0
  37. }).observe('.more', (res) => {
  38. if (this.status == 'loading' || this.status == 'noMore') return
  39. this.$emit('load')
  40. })
  41. },
  42. beforeDestroy() {
  43. this.Observer.disconnect()
  44. }
  45. }
  46. </script>
  47. <style lang="scss" >
  48. .zs-list{
  49. // height: calc(100vh - 100rpx);
  50. // overflow: auto;
  51. // margin-top: 100rpx;
  52. .more{
  53. width: 100%;
  54. }
  55. }
  56. </style>