diff --git a/packages/community/list/index.vue b/packages/community/list/index.vue index 8ec6d88f..f500a12d 100644 --- a/packages/community/list/index.vue +++ b/packages/community/list/index.vue @@ -124,9 +124,9 @@ export default { return item; }); - // 过滤出距离1km以内的数据 + // 过滤出距离1km以内的数据,确保距离为0的值也能被正确保留 processedList = processedList.filter(item => - item.distanceValue && item.distanceValue <= 1 + item.distanceValue !== undefined && item.distanceValue !== null && item.distanceValue <= 1 ); // 调用腾讯地图API获取附近1km的小区(包含图片信息) @@ -179,10 +179,10 @@ export default { mergedList = uniqueByField(mergedList, 'community_id'); } - // 根据距离排序 + // 根据距离排序,确保距离为0的值也能正确排序 mergedList.sort((a, b) => { - const distanceA = a.distanceValue || Infinity; - const distanceB = b.distanceValue || Infinity; + const distanceA = a.distanceValue !== undefined && a.distanceValue !== null ? a.distanceValue : Infinity; + const distanceB = b.distanceValue !== undefined && b.distanceValue !== null ? b.distanceValue : Infinity; return distanceA - distanceB; });