1. 맞춤 지침을 선언합니다.
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();
}
});
}
}
},
2. 사용자 정의 명령어 v-loadmore를 사용합니다.
<el-select filterable v-model="form.standardDevice" placeholder="请选择" clearable v-loadmore="loadMore" @change="handleChange">
<el-option v-for="item in deviceList" :key="item.deviceId" :label="item.deviceName" :value="item.serialNumber"></el-option>
<el-option v-if="selectLoading" v-loading="selectLoading" value=""></el-option>
</el-select>
3. 데이터 로드 요청 보내기
//滚动条滚动到底部
loadMore(){
//页数加一
this.pageNum ++
//发送网络请求
this.getDeviceList()
},