I've a v-for loop in my component and I need to update input value after I got it from the server. Below I provide full code of the component and my current issue - I don't understand how to change and even refer to any input. I marked in capital letters the row with code which does not work and provide more details after the code snippet
<template>
<div class="allPlaces__entrance" v-for="(entrance, index) in places.entrance" v-bind:key="index">
<div class="allPlaces__infoBlock">
<div>
<div class="allPlaces__available">
<span class="allPlaces__label allPlaces__label--places">Доступно мест:</span>
<span class="allPlaces__data"> {{entrance.vacant_places}}
</span>
</div>
<div class="allPlaces__title allPlaces__title--entrance">{{getEntranceName(entrance)}}</div>
</div>
<div class="allPlaces__price">
<span class="allPlaces__label">Цена: </span>
<span class="allPlaces__data">{{entrance.price}}</span>
</div>
</div>
<div class="allPlaces__orderBlock">
<div class="allPlaces__inputBlock">
<input class="allPlaces__input" type="number" name="amount" v-model="entrance.value" :ref="entrance.id" @blur="showLabel($event, index)">
<label class="allPlaces__label allPlaces__label--input"
@click="hideLabel($event, index)">Количество мест
</label>
</div>
</div>
</div>
</div>
</template>
script>
import vueMethods from '../../mixins/methods'
import { mapState } from 'vuex'
export default {
name: 'allPlaces',
mixins: [vueMethods],
data () {
return {
showTitle: ''
}
},
mounted () {
this.$nextTick(function () {
window.addEventListener('resize', this.updateAllPlacesOnResize)
this.setupAllPlaces()
})
},
watch: {
sessionId: function () {
console.log('this.sessionId ', this.sessionId);
// Как только создан seesionId запрашиваем колличество мест в корзине
this.getPlacesInCart();
let ref = this.$refs; // HERE IS MY ISSUE
console.log(this.$refs[15129]); // UNDEFINED
},
places: function () {
console.log(this.places.entrance[0].id);
}
},
computed: {
...mapState({
db: state => state.onload.eventData.currentDb,
agentId: state => state.onload.eventData.currentAgent,
eventId: state => state.onload.eventData.currentEvent,
modals: state => state.modals,
metric: state => state.onload.eventData.metric,
section: state => state.onload.eventData.section,
show: state => state.onload.eventData.show,
event: state => state.onload.eventData.event,
building: state => state.onload.eventData.building,
hall: state => state.onload.eventData.hall,
places: state => state.onload.eventData.places,
placesSeated: state => state.onload.eventData.places.place,
sessionId: state => state.cart.sessionId,
ticketsInCart: state => state.cart.ticketsInCart
})
}
}
</script>
The object I got when I call console.log(this.$refs);
{15129: [input.allPlaces__input]
15131: [input.allPlaces__input]
15132: [input.allPlaces__input]
15133: [input.allPlaces__input]
15137: [input.allPlaces__input]}
But if I call console.log(this.$refs[15129]);
, I'm getting undefined
Please advise