I have this code for a wordpress custom theme. I'm getting the data using the REST API and Vue.js to make the DOM change dynamically on click event. I'm facing a little problem, I'm not able to display the data with the layout I want, this because when I use the v-if
on the main row where I want to run my vue app, this will duplicate the row, but I want only to have the needed columns for the layout. I'm using bootstrap 4, and the columns are col-*-3
so inside a row it's supposed that there are four columns.
How I can fix this ?
<div class="row bg-light p-5 mt-3" v-for="cat in catList" >
<div class="col-sm-12 col-md-12 col-lg-12 p-0">
<div class="dropdown">
<a class="text-uppercase dropdown-toggle dropdown-toggle-split" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<?php _e('Collezioni'); ?>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a v-on:click="displayCategory(cat.id)" class="dropdown-item" href="#">{{ cat.name }}</a>
</div>
</div>
</div>
<div class="col-sm-12 col-md-3 col-lg-3 col-background shadow-lg mt-5 mb-5 p-0" data-bg-url="" style="height:50vh;"></div>
<div class="col-sm-12 col-md-3 col-lg-3 col-offset-top shadow-lg darkblue position-relative mt-5 mb-5 p-5">
<small class="text-white m-0"></small>
<h4 class="font-weight-bold text-white mt-2 mb-0" v-if="cat.name">{{ cat.name }}</h4>
<h4 class="font-weight-bold text-white mt-2 mb-0" v-else>{{ cat.title }}</h4>
<p v-if="cat.description">{{ cat.description }}</p>
<p v-else>{{ cat.content }}</p>
</div>
</div>
UPDATE
If I use a div <div v-for="cat in catList">
to wrap the content, the layout will break. See the screen
v-for
to adiv
inside... like this<div class="row bg-light p-5 mt-3"><div v-for="cat in catList">...</div></div>
– maxshuty<div v-for="">
will mess up the layout. See the attached screen in the question – guggio