比较此
return this.httpClient.get('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest', {params: data}).pipe(
map((x: any) => x.suggestions.map((y) => {
return {
...y,
title: y.text
};
})),
);
与此
return this.httpClient.get('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest', {params: data}).pipe(
map((x: any) => x.suggestions),
map((y: any) => y.title = y.text)
);
为什么这些情况不相等?
按预期进行的第一项工作,“删除”建议属性并将重复的属性文本复制到标题中>
第二个返回我一个值...而不是数组
我可以仅使用map()函数代替.map()吗?
比较此返回this.httpClient.get('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest',{params:data})。pipe(map((x:any )=> x.suggestions.map((y)=> ...
在第一个中,您正在使用.map()