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("滚动到底部了")
}
本文来自博客园,作者:zwbsoft,转载请注明原文链接:https://www.cnblogs.com/zwbsoft/p/16478884.html
电话微信:13514280351