Code Monkey home page Code Monkey logo

provinces-china's Introduction

ProvincesOfChina

city-data-element.js 是针对 element-ui 中,级联选择器设计的省市区数据。该数据来自国家统计局。

更新时间 2022-07-05

element-ui 中 Cascader 组件的使用示例

1. template 结构如下

<template>
  <div>
    <!-- options 是数据源 -->
    <!-- props 是配置对象 -->
    <el-cascader v-model="cascaderValue" :options="cityData" :props="cascaderProps" @change="onCascaderChange"></el-cascader>
  </div>
</template>

2. script 行为如下:

// 导入省市区县的数据
import cityData from './city-data-element.js'

export default {
  data() {
    return {
      // 挂载省市区县的数据
      cityData,
      // 用来保存级联选择器选中的值
      cascaderValue: [],
      // 级联选择器的配置对象
      cascaderProps: {
        expandTrigger: 'click',
        label: 'label',
        value: 'value',
        children: 'children'
      }
    }
  },
  methods: {
    // 监听级联选择器选中项改变的事件
    onCascaderChange() {
      console.log(this.cascaderValue)
    }
  }
}

相关链接

统计用区划和城乡划分代码

**省市区数据,适用于 Vant Area 组件

provinces-china's People

Contributors

liulongbin1314 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.