npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

element-china-checkbox

v1.5.0

Published

Element UI 级联 中国省市区数据 复选框

Downloads

25

Readme

Element UI 中国省市区级联数据-复选框-同时选择

安装

npm install element-china-checkbox -S

更新 2020年03月31日

  • 更新自定义省市区数据, 通过props的方式传入, 兼容之前版本
  • 如未传入自定义数据,则使用默认的省市区数据

示例

点击查看在线DEMO,初次打开会比较慢

图片示例

默认状态

默认状态

点击展开下拉菜单

点击展开下拉菜单

选中对应城市所有区域(全选)

选择区域

再次点击则可以取消全选

关闭下拉菜单

关闭下拉菜单

获取数据

  • 通过监听 getElData事件获取一个Object

    获取数据

// 数据格式如下
const checkData = {
  provinceId: this.provinceId, // 省份ID
  cityId: this.cityId, // 城市ID
  areaId: this.areaId, // 区县ID
}

使用

// 引入组件
import elementChinaCheckbox from 'element-china-checkbox'
// 注册组件
components: {
  elementChinaCheckbox
}
<!-- 使用组件并监听事件 getElData-->
<element-china-checkbox @getElData="getElData">
  确认选择
  <!-- 使用slot 可以传入自定义内容来替换默认文字 -->
</element-china-checkbox>

使用this.$refs来获取数据

  • 如果觉得按钮对整体风格有所影响,则可以通过传入 Submit=false 来控制是否显示按钮以及自定义事件
<element-china-checkbox :Submit="false"> </element-china-checkbox>
  • 使用this.$refs来获取数据
  const checkboxData = this.$refs.xxxx
  const province_id = checkboxData.provinceId
  const city_id = checkboxData.cityId
  const region_id = checkboxData.areaId

传入已选择的数据

<element-china-checkbox :Submit="false" :Selected="selectedData"> </element-china-checkbox>
/* 注意,数组内ID为String类型 */
const selectedData = {
  provinceId: [] // 已选择的省份
  cityId: [] // 已选择市级区域
  areaId: [] // 已选择的区县
}

数据来源

china-area-data v4.0.0

  • 请确保使用了china-area-data依赖包,否则将会缺少数据源

GitHub地址