VUE+elementUI前端实现 三级省市区联动select

VUE+elementUI前端实现 三级省市区联动select

HTML代码

	
	
		
		
	


	
	
		
		
	


	
	
    	
	    
    


   
   
     
     
     
     
JS代码
	import axios from 'axios';
	export default{
		data(){
			return {
				provinceValue:'',
				cityValue:'',
				areaValue:'',
				provinceData:[],
				cityData:[],
				areaData:[],
			}
		},
		created(){
			axios.get('https://static.panpay.com/static/nuxt/json/ChinaCity.json').then(res=>{
				this.provinceData = res.data;
			}).catch(e => {
				this.$message.error("网络连接超时");
		    })
		},
		methods:{
			chooseProvince(value){
				this.cityValue = '';
				this.areaValue = '';
				this.cityData = [];
				this.areaData = [];
				this.provinceData.map(e=>{//遍历数据
					if( value == e.name){
						this.cityData = e.cityList;
						return;
					}
				})
			},
			chooseCity(value){
				this.areaValue = '';
				this.cityData.map(e=>{//遍历数据
					if( value == e.name){
						this.areaData = e.areaList;
						return;
					}
				})
			},
			chooseArea(){
			}
		}
	}
	//JSON数据需要的请自行下载 谢谢

   
   
     
     
     
     

你可能感兴趣的:(element-ui,vue,三级省市区联动select)