分页功能:

1. 判断当前页和总页数
2. 追加数据
This commit is contained in:
jqtmviyu@gmail.com 2021-02-25 22:10:52 +08:00
parent 768ecbcabc
commit e24fdd64d3

View File

@ -41,7 +41,21 @@
</view>
</template>
<script>
<script>
// ,
const Params = {
//
query: "",
// id
cid: null,
//
pagenum: 1,
//
pagesize: 10
}
//
let TotalPage = 0
export default {
data(){
return{
@ -63,28 +77,33 @@ export default {
},
async onLoad ({ id }){
console.log(id)
const params = {
//
query: "",
Params.cid = id
this.getGoods()
},
// id
cid: id,
//
pagenum: 1,
//
pagesize: 10
//
onReachBottom(){
//
if(Params.pagenum >= TotalPage){
console.log("没有下一页数据了")
}else{
console.log("翻页")
Params.pagenum++
this.getGoods()
}
//
const {message} = await this.$u.api.getGoods(params)
console.log(message)
this.goods = message.goods
},
methods: {
//
async getGoods (){
const {message} = await this.$u.api.getGoods(Params)
console.log(message)
//
this.goods = [...this.goods, ...message.goods]
//
TotalPage = Math.ceil(message.total / Params.pagesize)
},
//
onTapsChange(index){
this.tabsCurrent = index
}