获取接口地址
    image.png

    1. <script>
    2. var url="http://47.108.197.28:3000/top/playlist?limit=36";
    3. $.ajax({
    4. url,
    5. success:res=>{
    6. var playlists=res.playlists;
    7. console.log(playlists);
    8. playlists.forEach(element => {
    9. var {name,coverImgUrl,playCount}=element;
    10. var nickname=element.creator.nickname;
    11. // console.log(name,coverImgUrl,nickname);
    12. // console.log(element);
    13. console.log(playCount)
    14. var cont= Math.round(playCount/10000);
    15. var t=`
    16. <div class="item">
    17. <div class="people">${cont}万</div>
    18. <img src="${coverImgUrl}" alt="">
    19. <p>${name}</p>
    20. <span>by${nickname}</span>
    21. </div>
    22. `
    23. $(".container").append(t); //将数据渲染到页面
    24. })
    25. }
    26. })
    27. </script>

    image.png