In my model, I have an array of images' URLs of varying lengths.
I want to display 2 images per row on my page, resulting in the following layout:
<div class="row">
<div class="col">
<img ... />
</div>
<div class="col">
<img ... />
</div>
</div>
<div class="row">
<div class="col">
<img ... />
</div>
<div class="col">
<img ... />
</div>
</div>
...
However, I am struggling to conditionally add the opening and closing tags of row
.
Here is the code snippet I attempted, but it's not functioning as expected:
I am utilizing Bootstrap-Vue, where b-container
, b-row
, and b-col
correspond to
<div class="container">
and <div class="col">
.
<b-container>
<template v-for="(url, index) in urls">
<template v-if="index % 2 == 0">
<b-row :key="index">
</template>
<b-col :key="index">
<p>{{ index }}</p>
<b-img
:src="url"
alt="charts"
fluid
></b-img>
</b-col>
<template v-if="index % 2 == 0">
</b-row>
</template>
</template>
</b-container>
Encountered Error:
Errors compiling template:
tag <b-row> has no matching end tag.
40 | <template v-for="(url, index) in urls">
41 | <template v-if="index % 2 == 0">
42 | <b-row :key="index">
| ^^^^^^^^^^^^^^^^^^^^
43 | </template>
44 | <b-col :key="index">