Files
ClassContent/历届学生/front-end-team/每天课程/2022-03-28/kuaishou/index.html
2024-09-27 02:06:13 +08:00

87 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>首页</title>
<style>
ul,
li {
margin: 0;
padding: 0;
list-style: none;
}
li {
width: 220px;
margin-right: 10px;
}
li img {
width: 100%;
}
ul {
display: flex;
flex-wrap: wrap;
}
</style>
</head>
<body>
<ul>
</ul>
<button>下一页</button>
</body>
<script src="./ajax.js"></script>
<script>
var pcursor = "";
function getIndex() {
http.get({
url: '/likeList',
data: {
pcursor: pcursor
},
success: function (res) {
pcursor = res.pcursor;
renderPage(res.feeds)
}
});
}
function renderPage(feeds) {
feeds.forEach(item => {
document.querySelector("ul").innerHTML += `
<li>
<a target="_blank" href="./play.html?principalId=${item.author.id}&photoId=${item.photo.id}">
<img src="${item.photo.coverUrl}" alt="">
<p>${item.photo.caption}</p>
</a>
</li>
`
});
}
document.querySelector("button").onclick = () => {
getIndex()
}
getIndex();
</script>
</html>