【发布时间】:2021-06-26 15:54:29
【问题描述】:
在这里使用 repo:https://github.com/country-regions/country-region-data/blob/master/data.js 我正在尝试绘制与该国家/地区相关的国家和城市。如果有人有任何建议,我不确定如何处理这个问题。
我想要这样,如果用户选择一个国家,如果有意义的话,城市字段只显示与该国家相关的区域?
这是我目前下面的代码,我使用地图来绘制国家/地区。但我不确定如何从所选国家/地区绘制区域?
<IonItem>
<IonLabel position={"stacked"}>Country</IonLabel>
<IonSelect interface="popover" value={values.country} name="country" placeholder="Select A Country" onIonChange={handleInputChange}>
{countries.map((country) => (
<IonSelectOption value={country.countryName} key={country.countryShortCode}>{country.countryName}</IonSelectOption>
))};
</IonSelect>
</IonItem>
<IonItem>
<IonLabel position={"stacked"}>City</IonLabel>
<IonSelect interface="popover" value={values.city} name="city" placeholder="Select A City" onIonChange={handleInputChange}>
{countries.map((country) => (
<IonSelectOption value={country.countryName} key={country.countryShortCode}>{country.countryName}</IonSelectOption>
))};
</IonSelect>
</IonItem>
【问题讨论】:
标签: javascript reactjs typescript dictionary ionic-framework