list.php 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template id="lo-list">
  2. <div class="list-contain" v-infinite-scroll="onReachBottom">
  3. <div class="list-content" v-for="(item,index) in list" flex :key="index">
  4. <span>{{item}}</span>
  5. </div>
  6. <slot v-if="isSlots" name="list" :item="123"></slot>
  7. </div>
  8. </template>
  9. <script>
  10. // 组件变量传不出去
  11. Vue.component('lo-list', {
  12. name: "lo-list",
  13. template: '#lo-list',
  14. props: {
  15. list: {
  16. type: Array,
  17. required: true,
  18. default () {
  19. return []
  20. }
  21. }
  22. },
  23. methods: {
  24. onReachBottom() {
  25. this.$emit("onReachBottom")
  26. }
  27. },
  28. computed: {
  29. isSlots() {
  30. console.log(this.$slots);
  31. return this.$slots.list
  32. }
  33. }
  34. });
  35. </script>
  36. <style>
  37. .list-contain {
  38. height: 100%;
  39. overflow: scroll;
  40. }
  41. </style>