码迷,mamicode.com
首页 > 其他好文 > 详细

vue 省市区三级联动

时间:2018-06-26 15:02:03      阅读:590      评论:0      收藏:0      [点我收藏+]

标签:list   html   func   val   eve   级联   三级联动   erro   v-model   

<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、结束------------->
 

vue 省市区三级联动

标签:list   html   func   val   eve   级联   三级联动   erro   v-model   

原文地址:https://www.cnblogs.com/CMing/p/9229021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!