1
i have a form and would like in the field (which is a select) to return (selected) the value previously marked.
Ex: if my selected is empty, the select
will display values normally (1, 2, 3, 4). If, it has value, my select
will show all values, but will come with the selected value 2 already.
<select v-model="item" style="height: 40px;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
data(){
return{
item: ''
}
},
mounted(){
this.api()
},
methods: {
api(){
axios.get(url)
.then(response => {
this.item = response.data.select
}
}
}
Can you explain better what you mean by "the value previously marked"? You mean it’s in the database? Or written somewhere?
– Sergio
@Sergio yes, this is filled in the item, ai case it comes from the marked base, it fills in the item, if it comes empty from the base, it will keep the item empty.
– Rafael Augusto
Okay, and how you pass server data to Javascript?
– Sergio
@Sergio Atualizei o codigo
– Rafael Augusto