在高德地图中使用autocomplete.current.search
搜索时如果输入xi
关键词就会出现高德的测试数据,如下
在应用中的表现就是数据错误,所以在使用autocomplete.current.search
方法时需先进行ID
的过滤,以此来保证程序的健壮性
如:
const addressResult =
(result.tips?.filter((item) => !!item.id) || []).map((item) => ({
label: `${item.district}${item.name}`,
value: item.id,
option: item
}));