安装与引用
<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-2 | Alpha-3 | Numeric |
|---|
模糊搜索 find(name)
根据国家或地区名称、Alpha-2、Alpha-3、Numeric 代码进行模糊匹配
API 说明
类型:function
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| name | string | 否 | - | 国家或地区名称、ISO 3166-1 代码 |
返回值:Country[]
iso3166_1.find("法国");
| 名称 | Alpha-2 | Alpha-3 | Numeric |
|---|
精确查询
使用 findOne / findByAlpha2 / findByAlpha3 / findByNumeric 精确匹配单个国家或地区
API 说明
iso3166_1.findOne("法国");