fix(form): select下拉列表分页不生效问题

This commit is contained in:
roymondchen 2023-02-21 15:40:29 +08:00
parent fcb69b7743
commit 8edf023a00

View File

@ -26,7 +26,7 @@
</template> </template>
<script lang="ts" setup name="MFormSelect"> <script lang="ts" setup name="MFormSelect">
import { inject, nextTick, onBeforeMount, onMounted, Ref, ref, watchEffect } from 'vue'; import { inject, onBeforeMount, Ref, ref, watch, watchEffect } from 'vue';
import { TMagicSelect } from '@tmagic/design'; import { TMagicSelect } from '@tmagic/design';
@ -331,10 +331,14 @@ if (typeof props.config.options === 'function') {
}); });
} }
props.config.remote && if (props.config.remote) {
onMounted(async () => { const unWacth = watch(
await nextTick(); () => tMagicSelect.value?.scrollbarWrap,
tMagicSelect.value?.scrollbarWrap?.addEventListener('scroll', async (e: Event) => { (scrollbarWrap) => {
if (!scrollbarWrap) {
return;
}
scrollbarWrap.addEventListener('scroll', async (e: Event) => {
const el = e.currentTarget as HTMLDivElement; const el = e.currentTarget as HTMLDivElement;
if (moreLoadingVisible.value) { if (moreLoadingVisible.value) {
return; return;
@ -350,7 +354,13 @@ props.config.remote &&
options.value = await getOptions(); options.value = await getOptions();
moreLoadingVisible.value = false; moreLoadingVisible.value = false;
}); });
}); unWacth();
},
{
immediate: true,
},
);
}
const popperClass = mForm?.popperClass; const popperClass = mForm?.popperClass;