fix: 下拉过滤器数据量大卡顿

This commit is contained in:
fit2cloud-chenyw
2022-06-27 15:39:41 +08:00
parent 63a0aa59af
commit 6deecb4569
3 changed files with 14 additions and 3 deletions

View File

@@ -4,8 +4,10 @@
v-model="selectValue"
:class="classId"
popper-class="VisualSelects"
no-match-text=" "
v-bind="$attrs"
v-on="$listeners"
@change="visualChange"
@visible-change="popChange"
>
<el-option v-for="item in options" :key="item.id" :label="item.text" :value="item.id" />
@@ -54,6 +56,9 @@ export default {
}
},
watch: {
value(val) {
this.selectValue = val
},
selectValue(val) {
this.$emit('update', val)
if (!val) {
@@ -102,6 +107,7 @@ export default {
)
this.scrollbar = document.querySelector(`.${this.classId} .el-select-dropdown .el-scrollbar`)
this.slectBoxDom = document.querySelector(`.${this.classId} .el-select-dropdown__wrap`)
if (!this.slectBoxDom || !this.slectBoxDom.style) return
this.slectBoxDom.style.display = 'flex'
this.slectBoxDom.style.flexDirection = 'row'
this.domList = selectDom.querySelector(
@@ -117,6 +123,7 @@ export default {
},
callback() {
if (!this.scrollbar) return
const scrollTop = this.scrollbar.scrollTop
this.startIndex = parseInt(scrollTop / this.itemHeight)
this.endIndex = this.startIndex + this.maxLength
@@ -129,6 +136,9 @@ export default {
this.resetList()
this.reCacularHeight()
},
visualChange(val) {
this.$emit('visual-change', val)
}
}