I'm trying to emit my v-for value (city) to a parent component.
<ul class="cards">
<li v-for="city in cities" :key="city">
<span @click="$emit('update-city', city">
<p @click="$emit('update-toggle')">{{item}}</p>
</span>
</li>
</ul>
The parent component looks like this
<template>
<span @update-city ="updatedCity = city">
<vertical-slider @update-toggle ="toggled= !toggled" :cities="citiesArray" v-if="toggled">
</vertical-slider>
</span>
<p>{{city}}</p>
</template>
<script>
data(){
return{
toggled: false,
updatedCity: "city",
citiesArray[City1, City2, City3]
}
</script>
The toggled event works fine and my cities get rendered as well. I just can't seem to be able to pass the city name to my parent component despite trying several combinations.
This should do the trick.
index.vueVerticalSlider.vue