I am working on a project where the selected country automatically determines the phone country code. I have set it up so that when I change the country, the corresponding country code should update as well.
https://i.sstatic.net/861tq.png
Within a customer object, both the country and countryCode are stored. Although the Vue dev tools show the country code changing when I trigger the change in country value, the related input does not reflect this change. Here is my code:
data: function () {
return {
customer: {},
countries: this.$store.state.settings.countries,
}
},
created: function() {
var defaultCountry = _.find(this.countries, { default: true });
this.customer.country = defaultCountry.name;
this.customer.countryCode = defaultCountry.code;
},
methods: {
updateCountryCode: function(country) {
this.customer.countryCode = country.code;
},
}
Here is the relevant HTML snippet:
<vSelect
label="name"
v-model="customer.country"
:options="countries"
:onChange="updateCountryCode">
</vSelect>
<input type="text" disabled :value="customer.countryCode">
Why does the data update correctly in dev tools but fail to render reactively, causing the country code input to remain unchanged?