mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
perf(components): [virtual-list] wrap row with Fragment and set key on it (#8284)
fix(components): [virtual-list] wrap row with Fragment and set key on it closed #8279 Co-authored-by: qiang <qw13131wang@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
Fragment,
|
||||
computed,
|
||||
defineComponent,
|
||||
getCurrentInstance,
|
||||
@@ -595,17 +596,21 @@ const createGrid = ({
|
||||
if (totalRow > 0 && totalColumn > 0) {
|
||||
for (let row = rowStart; row <= rowEnd; row++) {
|
||||
for (let column = columnStart; column <= columnEnd; column++) {
|
||||
const key = itemKey({ columnIndex: column, data, rowIndex: row })
|
||||
children.push(
|
||||
slots.default?.({
|
||||
columnIndex: column,
|
||||
data,
|
||||
key: itemKey({ columnIndex: column, data, rowIndex: row }),
|
||||
isScrolling: useIsScrolling
|
||||
? unref(states).isScrolling
|
||||
: undefined,
|
||||
style: getItemStyle(row, column),
|
||||
rowIndex: row,
|
||||
})
|
||||
h(
|
||||
Fragment,
|
||||
{ key },
|
||||
slots.default?.({
|
||||
columnIndex: column,
|
||||
data,
|
||||
isScrolling: useIsScrolling
|
||||
? unref(states).isScrolling
|
||||
: undefined,
|
||||
style: getItemStyle(row, column),
|
||||
rowIndex: row,
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
Fragment,
|
||||
computed,
|
||||
defineComponent,
|
||||
getCurrentInstance,
|
||||
@@ -484,13 +485,16 @@ const createList = ({
|
||||
if (total > 0) {
|
||||
for (let i = start; i <= end; i++) {
|
||||
children.push(
|
||||
($slots.default as Slot)?.({
|
||||
data,
|
||||
key: i,
|
||||
index: i,
|
||||
isScrolling: useIsScrolling ? states.isScrolling : undefined,
|
||||
style: getItemStyle(i),
|
||||
})
|
||||
h(
|
||||
Fragment,
|
||||
{ key: i },
|
||||
($slots.default as Slot)?.({
|
||||
data,
|
||||
index: i,
|
||||
isScrolling: useIsScrolling ? states.isScrolling : undefined,
|
||||
style: getItemStyle(i),
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user