I have a v-for loop iterating over an array called projects. I have another array called selectedProjects. When a project element is clicked, I'd like to add a class called selected to that specific element, as well as add the project.id property of that index to selectedProjects. Maybe I'm going about the whole problem wrong, is there a "vue" way to achieve this?
<!-- The template -->
<div v-for="project in projects" class="project" @click="">
<p><i class="fa fa-folder"></i>{{project.name}}</p>
</div>
The component's data:
data: function(){
return {
projects: [...],
selectedProjects: [],
}
},