zoukankan      html  css  js  c++  java
  • vue 省市区三级联动

    <select class="myCenter_add_row-5" v-model="province" :v-bind="province" @change="citychange($event)">
    <option v-for="i in provincelist" v-bind:value="i.id">{{i.name}}</option>
    </select>
    <select class="myCenter_add_row-5" v-model="city" @change="areachange($event)">
    <option v-for="k in citylist" v-bind:value="k.id">{{k.name}}</option>
    </select>
    <select class="myCenter_add_row-5" v-model="area">
    <option v-for="j in arealist" v-bind:value="j.id">{{j.name}}</option>
    </select>
    <!------------- html、结束------------->
    province: "",
    provincename: "",
    provincelist: [],
    city: "",
    cityname: "",
    citylist: [],
    area: "",
    areaname: "",
    arealist: [],
    <!------------- vue。js声明、结束------------->
    this.$http("/psys-enter/enterpriseBase/selectCityByLevel",{}, 0,1)
    .then(data => {
    this.provincelist=data.data;
    })
    .catch(error => {
     
    });
    <!------------- 一次性请求数据、结束------------->
    citychange: function() {
    let that = this;
    this.provincelist.forEach(function(i) {
    if (i.id == that.province) {
    that.provincename = i.name;
    that.citylist = i.sub;
    that.arealist = [];
    }
    });
    },
    areachange: function() {
    let that = this;
    this.citylist.forEach(function(i) {
    if (i.id == that.city) {
    that.arealist = i.sub;
    that.cityname = i.name;
    }
    });
    },
    this.arealist.forEach(function(i){
    if(that.area==i.id){
    that.areaname=i.name
    }
    })
    <!------------- js、结束------------->
     
  • 相关阅读:
    2017NOIP游记 (格式有点炸)
    Qtree3
    [P2769] 猴子上树
    [Usaco2005 Dec]Cleaning Shifts 清理牛棚
    [NOIP2014] 解方程
    [ZJOI2012] 灾难
    [洛谷P3941] 入阵曲
    [SCOI2009] 最长距离
    [JLOI2011] 飞行路线
    虚拟化数电底层
  • 原文地址:https://www.cnblogs.com/CMing/p/9229021.html
Copyright © 2011-2022 走看看