用el-select 如果option数量多 el-select就会很卡。
directives:{
'el-select-loadmore':(el,binding)=>{
cnost Dom=el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
if(Dom){
Dom.addEventListener('scroll',function(){
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
if(condition) binding.value()
})
}
}
},
data(){
return {
val:'',
pageNum:1,
pageSize:100,
options:[],
allOption:[]
}
}
methods:{
loadMore(){
return ()=>{
this.pageNum+=1
let arr = this.allOption.slice((this.pageNum-1)*this.pageNum,this.pageNum*this.pageSize)
this.options.push(...arr)
}
}
}
<el-select v-el-select-loadmore="loadMore" v-mode="val">
<option v-for="item in options"></option>
</el-select>