国家或地区 ISO 3166-1 代码
- 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 等包管理器安装,也可在项目根目录中添加
.npmrc文件,在其中加入一行@pomerun:registry=https://npm.pkg.github.com,这样安装依赖时可省略指定 GitHub Package 的 --registry 参数
安装依赖:
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 代码全部国家或地区列表
- 类型:
Country[]
搜索国家或地区
- 类型:
function - 参数:
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| name | string |
否 | - | 国家或地区名称、ISO 3166-1 代码 |
- 返回值:
Country[]
精确搜索国家或地区
- 类型:
function - 参数:
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| name | string |
否 | - | 国家或地区名称 |
- 返回值:
Country
使用 ISO 3166-1 Alpha-2 代码精确搜索国家或地区
- 类型:
function - 参数:
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| code | string |
否 | - | ISO 3166-1 Alpha-2 代码 |
- 返回值:
Country
使用 ISO 3166-1 Alpha-3 代码精确搜索国家或地区
- 类型:
function - 参数:
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| code | string |
否 | - | ISO 3166-1 Alpha-3 代码 |
- 返回值:
Country
使用 ISO 3166-1 Numeric 代码精确搜索国家或地区
- 类型:
function - 参数:
| 参数名 | 类型 | 是否可选 | 默认值 | 说明 |
|---|---|---|---|---|
| code | string |
否 | - | ISO 3166-1 Numeric 代码 |
- 返回值:
Country