分页功能:

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