I have utilized Bootstrap cards to display pricing information in my project. I implemented a collapse feature for half of the card when the screen size is equal to mobile width. While using vanilla Bootstrap, the animation worked seamlessly with the collapsing class as expected. However, after converting my project to Vue JS, the collapsing class stopped functioning entirely. The project is built entirely on Bootstrap and I have integrated a jQuery plugin into Vue. Below is a snippet of my code.
<template>
<div>
<div class="prices">
<div class="container">
<h1 class="comfortHeader" id="comfortHeader" style="margin-bottom: 50px;">Our Prices</h1>
<div class="d-flex row no-gutters justify-content-center">
<div class="card text-center mt-3" v-for="(price,i) in pricing" :key="i" id="body-collapsed">
<div class="card-body">
<h5 class="card-title">10 Lessons</h5>
<h5 id="biggerSize" class="card-title" style="font-weight: bold; padding-bottom:5px;padding-top:15px;">1,600 <span class="fas fa-tenge d-inline-block"></span></h5>
<p id="card-height" class="card-text">per lesson</p>
<p class="card-text">Total Payment: 16,000 KZT </p>
<button class="SeeTheCourse mt-5">Start Learning</button>
<a class="collapsed d-lg-none d-md-block"
data-toggle="collapse"
:data-target="'#collapseOne'+i"
aria-expanded="false"
aria-controls="collapseOne"
href="javascript:;"
@click.prevent="navItemCollapse(i)"
>
<span class="fa fa-chevron-down pull-bottom"></span>
</a>
<div id="collapseOne" v-if="price.items.length>0" class="collapse d-lg-block" :class="{show: price.expand}" aria-labelledby="body-collapsed">
<transition-group name="list">
<div v-for="(subItem,j) in price.items" :key="j">
<p id="lowerbodyparagraph" class="card-text">{{subItem.price1}}</p>
<p id="lowerbodyparagraph" class="card-text">{{subItem.price2}}</p>
<p id="lowerbodyparagraph" class="card-text" style="border-bottom: none;" >{{subItem.price3}}</p>
</div>
</transition-group>
</div>
</div>
</div>
<div v-for="(price,i) in pricing" :key="'k'+i" class="card text-center mt-3" id="body-collapsed2">
<div class="card-body">
<h5 class="card-title" >30 Lessons</h5>
<h5 id="biggerSize" class="card-title d-inline-block" style="font-weight: bold; padding-bottom:5px;padding-top:15px;">1,300 <span class="fas fa-tenge d-inline-block"></span></h5>
<p id="card-height" class="card-text">per lesson</p>
<p class="card-text">Total Payment: 39,000 KZT </p>
<p class="economyTariff">Save 9,000 KZT</p>
<button class="SeeTheCourse">Start Learning</button>
<a class="collapsed d-lg-none d-md-block"
data-toggle="collapse"
:data-target="`#collapseTwo+${i}`"
aria-expanded="false"
aria-controls="collapseTwo"
href="javascript:;"
@click.prevent="navItemCollapse(i)"
>
<span class="fa fa-chevron-down pull-bottom fa-md"></span>
</a>
<div id="collapseTwo" v-if="price.items.length>0" class="collapse d-lg-block" :class="{show: price.expand}" aria-labelledby="body-collapsed2">
<div v-for="(subItem,j) in price.items" :key="'l'+j">
<p id="lowerbodyparagraph" class="card-text">{{subItem.price4}}</p>
<p id="lowerbodyparagraph" class="card-text">{{subItem.price5}}</p>
<p id="lowerbodyparagraph" class="card-text" style="border-bottom: none;">{{subItem.price6}}</p>
</div>
</div>
</div>
</div>
<div v-for="(price,i) in pricing" :key="'p'+i" class="card text-center mt-3" id="body-collapsed3">
<div class="card-body">
<div class="sale">
Best Choice!
</div>
<h5 class="card-title">60 Lessons</h5>
<h5 id="biggerSize" style="color: #2FAFE5;font-weight: bold; padding-bottom:5px;padding-top:15px;" class="card-title">1,000 <span class="fas fa-tenge d-inline-block"></span></h5>
<p id="card-height" class="card-text">per lesson</p>
<p class="card-text">Total Payment: 60,000 KZT</p>
<p class="economyTariff">Save 16,000 KZT</p>
<button class="SeeTheCourse">Start Learning</button>
<a class="collapsed d-lg-none d-md-block"
data-toggle="collapse"
:data-target="`#collapseThree+${i}`"
aria-expanded="false"
aria-controls="collapseThree"
href="javascript:;"
@click.prevent="navItemCollapse(i)"
>
<span class="fa fa-chevron-down pull-bottom"></span>
</a>
<div id="collapseThree" v-if="price.items.length>0" class="collapse d-lg-block" :class="{show: price.expand}" aria-labelledby="body-collapsed3">
<div v-for="(subItem,j) in price.items" :key="'k'+j">
<p id="lowerbodyparagraph" class="card-text">{{subItem.price7}}</p>
<p id="lowerbodyparagraph" class="card-text">{{subItem.price8}}</p>
<p id="lowerbodyparagraph" class="card-text">{{subItem.price9}}</p>
<p id="lowerbodyparagraph" class="card-text" style="border-bottom: none;">{{subItem.price10}}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
import $ from 'jquery'
export default {
data(){
return{
pricing: [{
name: 'price1',
expand: false,
items: [{
id:1,
price1:"10 online lessons",
price2:"Interactive tasks",
price3:"Unlimited access to materials",
price4:"30 online lessons",
price5:"Interactive tasks",
price6:"Unlimited access to materials",
price7:"60 online lessons",
price8:"Premium support",
price9:"Feedback",
price10:"Unlimited access to materials"
},
]
}
],
}
}
methods: {
navItemCollapse(index) {
this.pricing = this.pricing.map((item, i) => {
item.expand = !item.expand
if (i !== index) {
item.expand = false
}
return item
})
},
},
}
</script>