el-select滚动到底部加载更多(分页加载数据)

自定义指令:

directives: {
'loadmore': {
inserted(el, binding) {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
SELECTWRAP_DOM.addEventListener('scroll', function() {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
}
}
},
引用自定义指令

<el-form-item v-if="ruleForm.organizationType == 1" label="站点:" prop="stationId">
<el-select placeholder="站点" v-model="ruleForm.stationId" :disabled="ruleForm.operatorId.length<=0" style="width:100%" v-loadmore="loadMore">
<el-option v-for="(n,i) in siteList" :key="i" :label="n.stationName" :value="n.id"</el-option>
</el-select>
</el-form-item>
methods:

loadMore() {
// 在这里请求接口加载数据
console.log("滚动到底部了")
}

posted @ 2022-07-14 18:25  zwbsoft  阅读(1118)  评论(0编辑  收藏  举报