
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@ophiuchus/area
Advanced tools
省市区三级联动选择,通常与弹出层组件配合使用。
import Vue from 'vue';
import Area from '@ophiuchus/area';
Vue.use(Area);
初始化省市区组件时,需要通过 area-list 属性传入省市区数据。
<sf-area title="标题" :area-list="areaList" />
areaList 为对象结构,包含 province_list、city_list、county_list 三个 key。
每项以地区码作为 key,省市区名字作为 value。地区码为 6 位数字,前两位代表省份,中间两位代表城市,后两位代表区县,以 0 补足 6 位。比如北京的地区码为 11,以 0 补足 6 位,为 110000。
示例数据如下:
const areaList = {
province_list: {
110000: '北京市',
120000: '天津市',
},
city_list: {
110100: '北京市',
120100: '天津市',
},
county_list: {
110101: '东城区',
110102: '西城区',
// ....
},
};
如果想选中某个省市区,需要传入一个 value 属性,绑定对应的省市区 code。
<sf-area title="标题" :area-list="areaList" value="110101" />
可以通过 columns-num 属性配置省市区显示的列数,默认情况下会显示省市区,当你设置为 2,则只会显示省市选择。
<sf-area title="标题" :area-list="areaList" :columns-num="2" />
可以通过 columns-placeholder 属性配置每一列的占位提示文字。
<sf-area
title="标题"
:area-list="areaList"
:columns-placeholder="['请选择', '请选择', '请选择']"
/>
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| value | 当前选中的省市区code | string | - |
| title | 顶部栏标题 | string | - |
| confirm-button-text | 确认按钮文字 | string | 确认 |
| cancel-button-text | 取消按钮文字 | string | 取消 |
| area-list | 省市区数据,格式见下方 | object | - |
| columns-placeholder | 列占位提示文字 | string[] | [] |
| loading | 是否显示加载状态 | boolean | false |
| readonly | 是否为只读状态,只读状态下无法切换选项 | boolean | false |
| item-height | 选项高度,支持 px vw vh rem 单位,默认 px | number | string | 44 |
| columns-num | 显示列数,3-省市区,2-省市,1-省 | number | string | 3 |
| visible-item-count | 可见的选项个数 | number | string | 6 |
| swipe-duration | 快速滑动时惯性滚动的时长,单位ms | number | string | 1000 |
| is-oversea-code | 根据code校验海外地址,海外地址会划分至单独的分类 | () => boolean | - |
| 事件 | 说明 | 回调参数 |
|---|---|---|
| confirm | 点击右上方完成按钮 | 一个数组参数,具体格式看下方数据格式章节 |
| cancel | 点击取消按钮时 | - |
| change | 选项改变时触发 | Picker 实例,所有列选中值,当前列对应的索引 |
| 名称 | 说明 |
|---|---|
| title | 自定义标题内容 |
| columns-top | 自定义选项上方内容 |
| columns-bottom | 自定义选项下方内容 |
通过 ref 可以获取到 Area 实例并调用实例方法,详见组件实例方法。
| 方法名 | 说明 | 参数 | 返回值 |
|---|---|---|---|
| reset | 根据 code 重置所有选项,若不传 code,则重置到第一项 | code?: string | - |
返回的数据整体为一个数组,数组内包含 columnsNum 个数据, 每个数据对应一列选项中被选中的数据。
code 代表被选中的地区编码, name 代表被选中的地区名称
[
{
code: '110000',
name: '北京市',
},
{
code: '110100',
name: '北京市',
},
{
code: '110101',
name: '东城区',
},
];
参见桌面端适配。
FAQs
### 介绍
The npm package @ophiuchus/area receives a total of 2 weekly downloads. As such, @ophiuchus/area popularity was classified as not popular.
We found that @ophiuchus/area demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.