NEZ-2842 feat: 处理valueList的滚动加载

This commit is contained in:
zhangyu
2023-06-06 10:12:55 +08:00
parent f6f577e895
commit 29c22d889c
2 changed files with 36 additions and 25 deletions

View File

@@ -1099,18 +1099,11 @@ let heightLoad = function () {
}
export const loadMore = {
bind (el, binding) {
console.log(el, binding)
console.log(el, binding, el.parentNode, 'bind')
// 获取element定义scroll
const selectDom = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
// selectDom.addEventListener('scroll', function (e) {
// console.log(e)
// const height = this.scrollHeight - this.scrollTop <= this.clientHeight
// if (height) {
// binding.value()
// }
// })
const selectDom = binding.dom ? el.querySelector(binding.dom) : el
heightLoad = function () {
const height = this.scrollHeight - this.scrollTop <= this.clientHeight
const height = this.scrollHeight - this.scrollTop - 20 <= this.clientHeight
if (height && el.hasMore) {
binding.value.load()
}
@@ -1121,7 +1114,8 @@ export const loadMore = {
el.hasMore = binding.value.hasMore
},
unbind (el, binding) {
const selectDom = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
const selectDom = binding.dom ? el.querySelector(binding.dom) : el
console.log(selectDom, 'unbind')
if (selectDom) {
selectDom.removeEventListener('scroll', heightLoad)
}