1. <template>
    2. <div class="home">
    3. <van-list
    4. class="home"
    5. v-model="loading"
    6. :finished="finished"
    7. finished-text="没有更多了"
    8. @load="onLoad"
    9. >
    10. <van-cell v-for="item of playlists" :key="item.id">
    11. <img class="item" v-lazy="item.coverImgUrl" alt="" />
    12. <p>{{ item.name }}</p>
    13. </van-cell>
    14. </van-list>
    15. </div>
    16. </template>
    17. <script>
    18. export default {
    19. name: "Home",
    20. data() {
    21. return {
    22. playlists: [],
    23. loading: false,
    24. finished: false,
    25. };
    26. },
    27. methods: {
    28. onLoad() {
    29. console.log(1)
    30. setTimeout(() => {
    31. var offset = this.playlists.length;
    32. this.axios.get(`http://47.108.197.28:3000/top/playlist?offset=${offset}&limit=20`).then((res) => {
    33. // console.log(res.data.playlists);
    34. var playlists = this.playlists.concat(res.data.playlists);
    35. this.playlists = playlists;
    36. this.loading = false;
    37. });
    38. }, 500);
    39. },
    40. },
    41. };
    42. </script>
    43. <style scoped>
    44. .item {
    45. width: 150px;
    46. height: 150px;
    47. }
    48. .home {
    49. display: flex;
    50. justify-content: space-around;
    51. flex-wrap: wrap;
    52. }
    53. .van-cell {
    54. width: 150px;
    55. }
    56. </style>