<div >没有更多了</p>
</div>
</div>
<style>
.infinite-list-wrapper {
width: 100%;
height: 300px;
border: 1px solid rebeccapurple;
}
.list {
width: 100%;
}
.list li {
height: 30px;
margin: 5px 0;
background: #8c939d;
list-style: decimal;
}
.infinite-list-wrapper p {
text-align: center;
}
</style>
<script>
(function () {
const vm = new Vue({
el:"#app",
data(){
return {
loading: false,
newsList:[],
pages:1,
currentPage:1
}
},
computed: {
noMore () {
return this.currentPage>=this.pages;
},
disabled () {
return this.loading || this.noMore
}
},
methods: {
load () {
this.loading = true;
axios.get("/news/get",{
params: {
pageNum: vm.currentPage+1,
pageSize:10
}
}).then(function (response) {
let pageInfo = response.data;
console.log(pageInfo);
pageInfo.data.forEach(function (item) {
vm.newsList.push(item);
});
vm.currentPage = pageInfo.current;
vm.loading = false;
}).catch(function (error) {
console.log(error);
})
}
},
created(){
axios.get("/news/get",{
params: {
pageNum: 1,
pageSize:10
}
}).then(function (response) {
let pageInfo = response.data;
console.log(pageInfo);
pageInfo.data.forEach(function (item) {
vm.newsList.push(item);
});
vm.pages = pageInfo.pages;
}).catch(function (error) {
console.log(error);
})
}
})
})();
</script>