I'm new to Vue.js and I guess I'm missing some point on the way it works. I'm trying to build the following:
- Fetch a list of plans from a REST API - done
- Display the plans as buttons with
v-for
- done - Allow the user to click in one of those buttons / plans to mark it as chosen
My code to print the buttons inside bootstrap columns:
<b-col lg="4" class="plan" v-for="plan in plans" :key="plan.id">
<b-button block variant="secondary" v-on:click="pickPlan(plan.id)">
<p class="price">€ {{plan.price}}</p>
<p class="plan">{{plan.name}}</p>
</b-button>
My problem: how can I make it so if the user clicks on some button it changes the property variant="primary"
in that button and sets all others to variant="secondary"
?
Thank you.