The el-select drop-down box handles paging data and bottoms out to load more

1. Declare custom instructions:

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. Use the custom command 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. Send a request to load data

//滚动条滚动到底部
loadMore(){
    //页数加一
    this.pageNum ++ 
    //发送网络请求
    this.getDeviceList()
},

Reference: el-select scrolls to the bottom to load more (load data in pages)_el-select bottoms out in pages_Tiandao rewards those who work hard_Lu's blog-CSDN blog

Guess you like

Origin blog.csdn.net/lq313131/article/details/131854820