当前位置: 首页 > news >正文

自定义滑动到底部触发指令,elementUI实现分页下拉框

在 main.js 中添加

// 自定义滑动到底部指令
Vue.directive('selectLoadMore', {bind(el, binding) {// 获取element-ui定义好的scroll盒子const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')SELECTWRAP_DOM.addEventListener('scroll', function () {if (this.scrollHeight - this.scrollTop < this.clientHeight + 1) {binding.value()}})},
})

使用

<el-selectclass="width-max"v-model="formValues.hpNumberArr"clearablefilterablemultiplereserve-keywordremotev-selectLoadMore="selectLoadMore":remote-method="remoteMethod"placeholder="请选择表型匹配"
><el-optionv-for="user in phenotypeList":key="user.id":label="user.label":value="user.value"></el-option>
</el-select>
// 下拉加载更多
selectLoadMore() {this.phenotypeSearch.pageNum = this.phenotypeSearch.pageNum + 1if (this.phenotypeList.length >= this.phenotypeSearch.totalPage) returnthis.readAllUsers() // 请求接口
},
// 远程搜索
remoteMethod(query, callback) {this.loading = truethis.phenotypeSearch.cn = querythis.phenotypeSearch.pageNum = 1this.phenotypeList = []callback && callback()setTimeout(() => {this.loading = falsethis.readAllUsers() // 请求接口}, 200)
},
// 获取数据
readAllUsers() {let params = {pageNum: this.phenotypeSearch.pageNum,pageSize: this.phenotypeSearch.pageSize,cn: this.phenotypeSearch.cn,}findListByConditionFun(params).then((res) => {this.phenotypeSearch.totalPage = res.data.totalRecordsthis.phenotypeList = this.phenotypeList.concat(res.data.data.map((i) => {return {id: i.id,value: i.hpNumber,label: i.cn,}}))})
},

image-20230823174334877

http://www.lryc.cn/news/136972.html

相关文章:

  • 【Windows 常用工具系列 10 -- linux ssh登录脚本输入密码】
  • C#的索引器
  • 软件配置安装(破解)--- maven下载配置
  • python解析小说
  • SQL Server 执行报错: “minus“ 附近有语法错误。
  • kali linux查看局域网下所有IP,并对指定IP攻击
  • 基于QCC_BES 平台的LMS自适应滤波算法实现
  • 大疆飞卡30运载无人机技术分享
  • 单片机的串口通信
  • 【C/C++】STL学习所得
  • leetcode几个数组题
  • 【LeetCode】模拟实现FILE以及认识缓冲区
  • 【Terraform学习】使用 Terraform 将 EC2 实例作为 Web 服务器启动(Terraform-AWS最佳实战学习)
  • WebGL 变量uniform、gl.getUniformLocation、gl.uniform4f及其同族函数相关
  • 【Visual Studio】生成.i文件
  • 本地生活服务平台加盟哪家公司好?
  • css-grid使用
  • springBoot提取一个List<?>中的某个字段集合
  • 【BUG】 ‘cv2.cv2‘ ‘wechat_qrcode_WeChatQRCode‘
  • 10 Mybatis
  • 【PHP】PHP的面向对象编程
  • Windows10突然出现音频无法正常运行的解决方法
  • Maven面试题大全及答案
  • 探究字符串匹配算法:暴力法与KMP算法的Java实现
  • 前端面试:【浏览器与渲染引擎】工作原理与渲染流程
  • PySide6学习笔记--gui小模版使用
  • 如何用Python实现冒泡排序
  • C++Qt堆叠窗体的使用案例
  • Linux之套接字UDP实现网络通信
  • Matlab绘制二值图像