制作一个多选择器,先得到州,然后得到城市.反应


I am having trouble finding a solution  to use this api to make a multi-selector that gets The state first then the city.
this is the API = https://corona.lmao.ninja/v2/jhucsse/counties/:countyName

这个API打印出这样的JSON数据,带有与每个Array 相关的省和县

"country": "US",
"province": "South Carolina",
"county": "Abbeville",
"updatedAt": "2020-05-07 02:32:28",
"stats": {
"confirmed": 33,
"deaths": 0,
"recovered": 0
},
"coordinates": {
"latitude": "34.22333378",
"longitude": "-82.46170658"
}
},```
How could I make a multi-selector that Selects the province first then out of that province it selects all counties associated with it?

您需要首先为省进行筛选,然后映射筛选器的resuling数组,将县添加到您的"results"数组中。

const result =  response.filter(entry => entry.province === "South Carolina").map(entry => entry.county)

相关内容

最新更新