Jea*_*rre 4 javascript iso dictionary ecmascript-6
拥有国家 ISO 代码列表,可在此处供参考:
有没有办法从中返回国家名称?
例如,有一个函数 ,getCountryName()如果调用该函数getCountryName('AL')将返回“阿尔巴尼亚”等。
我这样做是为了保存整个列表并像使用字典一样对其进行处理,但我想知道是否有一种方法无需将整个国家/地区保存到列表中。
Mam*_*mun 15
您可以尝试Intl.DisplayNames()ECMAScript 国际化 API Intl:
var getCountryNames = new Intl.DisplayNames(['en'], {type: 'region'});
console.log(getCountryNames.of('AL')); // "Albania"Run Code Online (Sandbox Code Playgroud)