郑永安
2023-06-19 c8188c0fc9edf6ea3feda5b6f11dcb014af2a89e
1
2
3
4
5
6
7
8
9
10
11
12
13
import Vue from 'vue';
Vue.directive('loadmore', {
  bind(el, binding) {
    // 获取element-ui定义好的scroll盒子
    const selectEle = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
    selectEle.addEventListener('scroll', function() {
      const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
      if (condition) {
        binding.value();
      }
    });
  }
});