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