@pomerun/iso-3166-1

国家或地区 ISO 3166-1 代码

共收录 -- 个国家或地区,支持名称模糊搜索及 Alpha-2 / Alpha-3 / Numeric 代码精确查询

支持环境:Node.js ≥ 21 · Chrome ≥ 117(更低版本需自行根据框架处理降级或 polyfill)

安装与引用

<script src="build/index.iife.js"></script>
<script>
    const iso3166_1 = new ISO3166_1();

    iso3166_1.list; // 全部国家或地区列表
    iso3166_1.find("法国"); // 获取与 法国 相关的 ISO 3166-1 代码
</script>
npm i @pomerun/iso-3166-1 --registry=https://npm.pkg.github.com
import ISO3166_1 from "@pomerun/iso-3166-1";

const iso3166_1 = new ISO3166_1();

iso3166_1.list; // 全部国家或地区列表
iso3166_1.find("法国"); // 获取与 法国 相关的 ISO 3166-1 代码
npm i @pomerun/iso-3166-1 --registry=https://npm.pkg.github.com
const ISO3166_1 = require("@pomerun/iso-3166-1");

const iso3166_1 = new ISO3166_1();

iso3166_1.list; // 全部国家或地区列表
iso3166_1.find("法国"); // 获取与 法国 相关的 ISO 3166-1 代码

全部列表 list

API 说明

类型:Country[]

名称Alpha-2Alpha-3Numeric

模糊搜索 find(name)

根据国家或地区名称、Alpha-2、Alpha-3、Numeric 代码进行模糊匹配

API 说明

类型:function

参数名类型是否可选默认值说明
namestring否-国家或地区名称、ISO 3166-1 代码

返回值:Country[]

iso3166_1.find("法国");
名称Alpha-2Alpha-3Numeric

精确查询

使用 findOne / findByAlpha2 / findByAlpha3 / findByNumeric 精确匹配单个国家或地区

API 说明
iso3166_1.findOne("法国");