fix: optimize data loading in ParagraphList component
This commit is contained in:
parent
79537cade9
commit
28a909e226
@ -70,14 +70,20 @@ const props = defineProps({
|
|||||||
knowledgeId: String
|
knowledgeId: String
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 初始化加载数据
|
||||||
|
watchEffect(() => {
|
||||||
|
if (props.modelValue && props.modelValue.length > 0) {
|
||||||
|
const end = page_size.value * current_page.value;
|
||||||
|
localParagraphList.value = props.modelValue.slice(0, Math.min(end, props.modelValue.length));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// 监听分页变化,只加载需要的数据
|
// 监听分页变化,只加载需要的数据
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
const start = 0;
|
const start = 0;
|
||||||
const end = page_size.value * current_page.value;
|
const end = page_size.value * current_page.value;
|
||||||
// 只获取所需数量的数据,而不是每次都对整个数组进行切片
|
// 不管数据量多少,都确保获取所有应该显示的数据
|
||||||
if (end <= props.modelValue.length) {
|
localParagraphList.value = props.modelValue.slice(start, Math.min(end, props.modelValue.length));
|
||||||
localParagraphList.value = props.modelValue.slice(start, end);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const paragraph_list = computed(() => {
|
const paragraph_list = computed(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user