代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>lyf音乐</title>
<style>
body{
margin: 0;
padding:0;
}
body>.title{
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 50px;
background: rgb(77, 85, 237);
text-align: center;
line-height: 50px;
font-size: 30px;
color: aliceblue;
z-index: 9;
}
.list{
padding: 50px 10px 10px;
box-sizing: border-box;
}
.list .item{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
}
.img-wrap{
position: relative;
width: 20vw;
height: 20vw;
background-color: rgb(227, 242, 237);
overflow: hidden;
border-radius: 10px;
}
.img-wrap img{
position: absolute;
top: 50%;
width: 100%;
transform: translateY(-50%);
}
.item .title{
width: 63vw;
height: 50px;
font-size: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.item .play{
font-size: 30px;
}
</style>
<script src="./js/axios.js"></script>
</head>
<body>
<div class="title">lyf音乐</div>
<div class="list" id="list">
<!-- <div class="item">
<div class="img-wrap">
<img src="" alt="" srcset="">
</div>
<div class="title">我事个名字和萨哈哈哈哈哈哈哈哈哈</div>
<div class="play">▶️</div>
</div> -->
</div>
</body>
<script>
window.onload=()=>{
let list=document.getElementById("list")
axios.get("/musicApi/top/artists?offset=0&limit=30").then(res=>{
if(res.status==200){
let str=""
res.data.artists.forEach(item=>{
let url=item.picUrl+'?param=200y200'
str+=`
<div class="item" data-id="${item.id}" data-url="${item.picUrl+'?param=200y200'}">
<div class="img-wrap">
<img src="${url}" >
</div>
<div class="title">${item.name}</div>
<div class="play">...</div>
</div>
`
})
list.innerHTML=str
setTimeout(() => {
let items=list.querySelectorAll(".item")
items.forEach((i,index)=>{
i.onclick=()=>{
let id=res.data.artists[index].id
let url=res.data.artists[index].picUrl
window.location.href=`/music/playerDetail.html?id=${id}&src=${url}`
}
})
}, 500);
}
})
}
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。