其他分享
首页 > 其他分享> > el-select滚动到底部加载更多(分页加载数据)

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("滚动到底部了")
}

标签:el,自定义,DOM,binding,select,加载
来源: https://www.cnblogs.com/zwbsoft/p/16478884.html