• vue使用ant design Vue中的a-select组件实现下拉分页加载数据


              :labelCol="labelCol"

              :wrapperCol="wrapperCol"

              prop="equipmentTypeId"

              label="所属设备种类">

              v-model="model.equipmentTypeId" @popupScroll="handlePopupScroll" placeholder="请选择所属设备种类 " mode="multiple">

                v-for="(item, index) in typeList" :value="item.id" :key="item.id">

                  {{ item.equipmentTypeName }}

               

             

           

    import { getDeviceTypeList } from '@/api/home'

    export default {

       data () {

            typeList: [],

            pageObj: {

              pageNo: 1,

              pageSize: 10,

              pages: 0, // 总页数

              total: 0, // 总条数

            }

       }

    }

    methods: {

          // 下拉列表滚动时的回调

          handlePopupScroll (e) {

            console.log(e)

            if (this.pageObj.pageNo >= this.pageObj.pages) return;

            const { target } = e;

            const { scrollTop, scrollHeight, clientHeight } = target;

            if (scrollTop + 2 + clientHeight >= scrollHeight) {

              // 已经到达底部,触发分页逻辑

              // todo 这里就可以触发加载下一页请求  具体函数根据当前业务需求来定

              this.pageObj.pageNo = ++this.pageObj.pageNo;

              this.pageObj.pageSize+1

              this.getTypeList(true)

            }

          },

          getTypeList(isScroll = false) {

            let param = {

              pageNo: this.pageObj.pageNo,

              pageSize: this.pageObj.pageSize

            }

            getDeviceTypeList(param).then((res) => {

              if (res.success) {

                this.pageObj.pages = res.result.pages;

                this.typeList = isScroll == false ? [] : this.typeList;

                res.result.records.forEach((e) => {

                  // 成功之后的数据应该push进数组中,而不是直接等于,否则就是下拉换页的效果了。

                  this.typeList.push(e);

                });

              }

            })

          },

    }

     

  • 相关阅读:
    老卫带你学---leetcode刷题(17. 电话号码的字母组合)
    leetcode困难之1127. 用户购买平台
    【Maven学习】3.7 实验七:测试依赖的传递性
    Reflection - 浅谈Python反射
    vscode setting.json 全局设置 工作区设置 位置 优先级
    突破从0到1后,鲜花电商2.0时代怎么走?
    软件工程毕业设计课题(14)基于python的毕业设计python运动场地预约系统毕设作品源码
    6143. 预算内的最多机器人数目--(每日一难phase2--day7)
    imx6ull pro BSP 工具链
    【计算机网络】数据链路层重点协议
  • 原文地址:https://blog.csdn.net/qq_42080594/article/details/133813447