• 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);

                });

              }

            })

          },

    }

     

  • 相关阅读:
    12.反射与动态代理
    在uni-app中使用手机号一键登录
    微信支付V3开发问题-V3构造失败原因:java.security.InvalidKeyException: Illegal key size
    20 个提升效率的 JS 简写技巧
    FD-Align论文阅读
    索尼cfa卡格式化了怎么恢复数据?这2种方法请收好
    前后端分离-图书价格排序案例、后端返回图片地址显示在组件上(打印图片地址)
    HT4344 2通道 立体声 DAC转换器的特性
    文心一言 VS 讯飞星火 VS chatgpt (113)-- 算法导论10.2 5题
    IDE助力提高生产力
  • 原文地址:https://blog.csdn.net/qq_42080594/article/details/133813447