I have a select where I am trying to set the :selected value to data from my server on page load. All the data is accessible but I am not sure what I am missing. My prop customer is an object that is passed in from the parent and comes from the backend. The value of customer.state is the abbreviated state , so "CA" for example. I tried doing :selected="this.customer.state" but that didn't work either.
data() {
return {
this.states = [
{text: "California", value: "CA"},
{text: "New Jersey", value: "NJ"},
//etc
],
}
},
props: {
customer: {type: Object}
}
<select name="state" autocomplete="address-level1" @change="optionDropdown">
<option v-for="x in optionsReturned" :value="x.value" :selected="???">
{{ x.text }}
</option>
</select>