En fazla bu kadar kısaltabildim. Dahada kısalır mı bilmiyorum. Şu an ki haliyle yarı yarıya kodlar azalmış oldu.
<script>
export default {
name: 'TestArayuzu',
data(){
return { sehir: '', ulke: 0, ilce: '', iller: null, ilceler: null }
},
props: {
v: { type: Object, default:{} }, l: { type: Object, default: {} },
},
methods:{
Sc: function (d){ this.iller = d; },
Ic: function (d){ this.ilceler = d; },
sIL: function (){
axios({ url: this.v.axiosurl, method: 'post', responseType: 'json', data: { u: this.v.ulkeler[this.ulke] }})
.then((response) => { this.Sc(response.data.iller[0].ilceler); })
.catch(function (error){ console.log(error) });
},
sILCE: function (){
axios({ url: this.v.axiosurl, method: 'post', responseType: 'json', data: { u: this.sehir } })
.then((response) => { this.Ic(response.data.iller[0].ilceler); })
.catch(function (error){ console.log(error) });
}
},
watch: {
ulke: function (y,e){
if(y=='TR'){
this.sIL()
}else if(e=='TR'){
this.iller = null;
this.ilceler = null;
this.sehir = '';
this.ilce = '';
$('#sehir').selectpicker('destroy');
$('#ilce').selectpicker('destroy');
}
},
sehir: function (){
if(this.ulke=='TR'){
this.sILCE()
}
}
},
updated: function(){
this.$nextTick(function(){ $('.selectpicker').selectpicker('refresh'); });
}
}
</script>