Vue+elemenUI 省市区三级联动

<el-form-item label="省">
	<el-select v-model="form.province" @change="gengxin1">
    	<el-option v-for="item in address" :value="item.sheng">{{item.sheng}}</el-option>
    </el-select>
</el-form-item>
<el-form-item label="市">
    <el-select v-model="form.city" @change="gengxin2">
       <el-option v-for="item in citys" :value="item.shi">{{item.shi}}</el-option>
    </el-select>
</el-form-item>
<el-form-item label="县">
     <el-select v-model="form.county">
        <el-option v-for="item in countys" :value="item">{{item}}</el-option>
     </el-select>
</el-form-item>
import address from '@/assets/json/address'//建议放在assets文件夹下 | address.json(下面有链接)

data() {
  return {
    address: address,
    citys: [],
    countys: []
  }
}
gengxin1() {
  const _this = this
  _this.address.forEach(function(item,index) {
    if (item.sheng === _this.form.province) {
      _this.citys = item.city
    }
  })
  _this.form.city = _this.citys[0].shi
  this.gengxin2()
},
gengxin2() {
  const _this = this
  _this.citys.forEach(function(item,index) {
    if (item.shi === _this.form.city) {
      _this.countys = item.qx
    }
  })
  _this.form.county = _this.countys[0]
}

json数据

https://hakupload.oss-cn-beijing.aliyuncs.com/Mabatis-plus/json/address.json

json数据来着:https://www.cnblogs.com/z-hj/p/12963460.html

vux 省市县数据 内容描述: export const address=[{ name: "北京市", parent: "0", value: "110000" }, { name: "北京市", parent: "110000", parentAreaName: "北京市", value: "110100" }, { name: "东城区", parent: "110100", parentAreaName: "北京市", value: "110101" }, { name: "西城区", parent: "110100", parentAreaName: "北京市", value: "110102" }, { name: "朝阳区", parent: "110100", parentAreaName: "北京市", value: "110105" }, { name: "丰台区", parent: "110100", parentAreaName: "北京市", value: "110106" }, { name: "石景山区", parent: "110100", parentAreaName: "北京市", value: "110107" }, { name: "海淀区", parent: "110100", parentAreaName: "北京市", value: "110108" }, { name: "门头沟区", parent: "110100", parentAreaName: "北京市", value: "110109" }, { name: "房山区", parent: "110100", parentAreaName: "北京市", value: "110111" }, { name: "通州区", parent: "110100", parentAreaName: "北京市", value: "110112" }, { name: "顺义区", parent: "110100", parentAreaName: "北京市", value: "110113" }, { name: "昌平区", parent: "110100", parentAreaName: "北京市", value: "110114" }, { name: "大兴区", parent: "110100", parentAreaName: "北京市", value: "110115" }, { name: "怀柔区", parent: "110100", parentAreaName: "北京市", value: "110116" }, { name: "平谷区", parent: "110100", parentAreaName: "北京市", value: "110117" }, { name: "密云区", parent: "110100", parentAreaName: "北京市", value: "110118" }, { name: "延庆区", parent: "110100", parentAreaName: "北京市", value: "110119" }]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值