下拉框数据下拉刷新

本文介绍了如何在Vue应用中使用el-select组件进行远程数据加载,并实现分页查询,配合自定义指令处理滚动事件,以便动态加载更多入驻企业选项。
摘要由CSDN通过智能技术生成

<el-select
           v-model="form.enterpriseName"
           style="width: 100%"
           v-loadmore="selectLoadMore" //自定义指令
           placeholder="请选择"
           filterable
           clearable
           remote
           ref="searchSelect"
           :remote-method="selectLoadMore"
           @clear="selectLoadMore('')"
           @change="handleSelectEnterprise($event)"
         >
              <el-option v-for="(item, index) in enterpriseList" :key="index" :label="item.enterpriseName" :value="item.inTheEnterpriseId"></el-option>
                  </el-select> 






//自定义指令
directives: {
      loadmore: {
        bind(el, binding) {
          const DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
          DOM.addEventListener('scroll', function () {
            const condition = this.scrollHeight - this.scrollTop < this.clientHeight + 1

            if (condition) {
            // 如果绑定了函数 则调用那个函数,此处binding.value就是selectLoadMore方法
              binding.value()
            }
          })
        },
      },
    },



 //分页查询入驻企业
      selectLoadMore(data) {
        const isClear = data !== undefined
        this.searchVal = isClear ? data : this.searchVal

        if (isClear) {
          this.currentPage = 1
        } else {
          this.currentPage = this.currentPage + 1 //查询搜索参数
          if (this.currentPage > this.enterpriseTotal) return
        }
        this.handleInEnterpriseList(this.searchVal, isClear) //查询方法
      },

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值