获取接口地址
<script>
var url="http://47.108.197.28:3000/top/playlist?limit=36";
$.ajax({
url,
success:res=>{
var playlists=res.playlists;
console.log(playlists);
playlists.forEach(element => {
var {name,coverImgUrl,playCount}=element;
var nickname=element.creator.nickname;
// console.log(name,coverImgUrl,nickname);
// console.log(element);
console.log(playCount)
var cont= Math.round(playCount/10000);
var t=`
<div class="item">
<div class="people">${cont}万</div>
<img src="${coverImgUrl}" alt="">
<p>${name}</p>
<span>by${nickname}</span>
</div>
`
$(".container").append(t); //将数据渲染到页面
})
}
})
</script>