I have built the project, but I can't display the data to be three columns in each row.
Here is my code:
<template>
<div>
<p v-if="$fetchState.pending">Fetching products...</p>
<p v-else-if="$fetchState.error">An error occurred :(</p>
<div v-else>
<h1>Lab Türkiye products</h1>
<div v-for="product in products" :key="product.id">
<img
title="Card Title"
:src="product.images[0]"
img-alt="Image"
img-top
tag="article"
style="max-width: 20rem"
class="mb-2"
/>
<h3>{{ product.description }}</h3>
<h4>{{ product.price }} TL</h4>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
numCols: 3;
return {
products: [],
};
},
async fetch() {
const response = await this.$axios.$get("https://dummyjson.com/products");
this.products = response.products;
},
};
</script>
<style>
h1 {
bottom: 57px;
width: 500px;
margin: 10px 10px 10px 410px;
margin: 10 20 30 10;
text-align: center;
color: yellowgreen;
}
</style>
There are 30 products coming from an API, I want them to be organised as three columns in each row.
It shouldn't be bootstrap, I could use any CSS library or even vanilla CSS.