flat: 演示版
This commit is contained in:
@@ -70,8 +70,29 @@ watch(
|
||||
() => props.list,
|
||||
(newList) => {
|
||||
if (!Array.isArray(newList)) return;
|
||||
|
||||
let shouldReset = false;
|
||||
|
||||
if (dataSource.value.length > newList.length) {
|
||||
shouldReset = true;
|
||||
} else if (dataSource.value.length > 0 && newList.length > 0) {
|
||||
// 注意:这里沿用你代码中使用的 item.id 作为唯一标识
|
||||
const oldId = dataSource.value[0].id;
|
||||
const newId = newList[0].id;
|
||||
if (oldId !== newId) {
|
||||
shouldReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldReset) {
|
||||
dataSource.value = [];
|
||||
processedIds.clear();
|
||||
}
|
||||
|
||||
const newItems = newList.filter((item) => !processedIds.has(item.id));
|
||||
|
||||
if (newItems.length === 0) return;
|
||||
|
||||
newItems.forEach((item) => processedIds.add(item.id));
|
||||
const delay = 50;
|
||||
newItems.forEach((item, index) => {
|
||||
@@ -80,7 +101,7 @@ watch(
|
||||
}, index * delay);
|
||||
});
|
||||
},
|
||||
{ immediate: true }
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
function nextDetail(company) {
|
||||
|
||||
Reference in New Issue
Block a user