自定义指令:
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="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("滚动到底部了")
}