fix: 修正product-list的遍历问题

This commit is contained in:
2025-11-08 15:42:03 +08:00
parent bd894d6f2e
commit a34cfaff6f

View File

@ -8,7 +8,7 @@
<div class="products-container">
<el-collapse v-model="activeNames" class="product-collapse">
<el-collapse-item
v-for="[key, value] in groupedProducts"
v-for="[key, value] in Object.entries(groupedProducts)"
:key="key"
:title="key || '未分类'"
:name="key || 'no-category'"
@ -64,9 +64,9 @@
}
groups[typeKey]?.data.push(prod);
}
const sortedGroups = Object.entries(groups)
.sort(([, a], [, b]) => a.sort - b.sort)
.map(([key, value]) => [key, value]);
const sortedGroups = Object.fromEntries(
Object.entries(groups).sort(([, a], [, b]) => a.sort - b.sort)
);
return sortedGroups;
});