Vue 3 allows for creating multiple cards with unique contents

I received this outcome: Content duplicated but not cloned as a card element

Below is the code snippet

<script setup>
import { ref } from 'vue';

defineProps({
  project: String,
});

const projectList = ref([
  {
    img: './src/assets/img/Pp.png',
    tag: 'React JS',
    name: 'Destination List App',
    desc: 'Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas..',
  },
  {
    img: './src/assets/img/PP2.png',
    tag: 'HTML CSS JS',
    name: 'City Specialties App',
    desc: 'Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas..',
  },
]);
</script>

And here is the template markup

<div>
  <!-- I want this entire block below to be replicated -->
  <div class="col-md-4">
    <div class="card card--project">
      <img class="card__img" v-for="project in projectList" v-bind:key="project.img" :src="project.img" alt="" />
      <div class="card__text">
        <p class="project-label text-md text-md--md" v-for="project in projectList" v-bind:key="project.tag">{{ project.tag }}</p>
        <h4 class="text-gradient-primary" v-for="project in projectList" v-bind:key="project.name">{{ project.name }}</h4>
        <p class="project-desc text-md" v-for="project in projectList" v-bind:key="project.desc">{{ project.desc }}</p>
        <a href="#" class="links">Read More</a>
      </div>
    </div>
  </div>
</div>

I aim to create a section of cards that resembles the design above

Answer №1

When it comes to multiplying elements in your comments, remember that looping through each individual component like images and tags won't achieve the desired result. To effectively replicate an entire element, you need to loop through the entire card container.

<div>
   <!-- This entire block below should be duplicated -->
   <div class="col-md-4" v-for="(project,id) in projectList" v-bind:key="project.id">
        <div class="card card--project">
       <img class="card__img" :src="project.img" alt="" />
       <div class="card__text">
        <p class="project-label text-md text-md--md">{{ project.tag }}</p>
        <h4 class="text-gradient-primary">{{ project.name }}</h4>
        <p class="project-desc text-md">{{ project.desc }}</p>
        <a href="#" class="links">Read More</a>
      </div>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance your textbox with more detailed descriptions than just displaying NaN

I am working on a form that includes select boxes. If a user selects an option from "Convert From" and another option from "Convert To" but does not enter a number in the input field, instead of displaying NaN in the result text box, I would like to show ...

Handling Vuex: Attempting to execute a code block within a Getter

I am experiencing an issue with my Vue getter method: getVipCustomersKeys(state) { if (state.vipCustomers) { let arr = []; for (x in state.vipCustomers) { arr.push(x); } } return arr; }, Upon inspecting the ...

When the button is clicked, bind the value to an object using the specified key in

I'm fairly new to Vue and I'm looking to generate buttons based on my data and show their information when clicked. The 'pets' object contains keys for id and info. (My actual data is more extensive and my code is a bit more complex, bu ...

Centralizing the Accordion header and expansion icon in React with Material-UI

I'm currently incorporating the Accordion feature from Material-UI library into my React project: My goal is to ensure that the accordion summary (header with "Accordion 1", "Accordion 2") is centered, and the expand icon (arrow) is also centered rig ...

Adjusting the Underline Navigation Effect with jQuery

My current setup includes a basic navbar with an up arrow that slides underneath it when a navigation title is clicked. The arrow initially rests between two nav titles, and when one of them is clicked, some text also slides in. I am looking to implement ...

inadequately arranged in a line

In Bootstrap 4, I have created this form group that you can view in this fiddle: <div class="m-portlet__body"> <div class="form-group m-form__group row"> <label class="col-lg-2 col-form-label"> Email Address ...

Tips for placing a large image within a small div

I have an image with a ratio of 1920*1300 that I want to be displayed on any device the website is viewed and cover the entire div. Check out my code below: .carousel { width: 100vw; height: 80vh; position: relative; } .carousel a { width: 1 ...

Get rid of the "clear field" X button for IE11 on Windows 8

After trying out the suggestions provided in Remove IE10's "clear field" X button on certain inputs? .someinput::-ms-clear { display: none; } I successfully removed the X button on IE 11 running on Windows 7, but unfortunately it didn&a ...

Persistent footer text moving around

Check out the sticky header I created here. However, when it sticks in place, the text moves down and goes out of the container. I want the header to remain within the container. Here is my HTML & jQuery: <div id="container"> <div id="menu ...

Adjustable block with excess content

Forgive me if this question seems basic, but I'm not very familiar with CSS. I have a table with two columns that need to be equally sized and responsive when the page is resized. The header isn't an issue since it only contains a few words in ...

What is the correct way to properly deploy Nuxt.js in SPA mode on a server?

My current project involves utilizing Nuxt.js in Single Page Application (SPA) mode. However, I am encountering difficulties when trying to deploy it on my Apache server. Has anyone else faced this issue before? I suspect that the problem may be related t ...

Issues with displaying PNG background images in older versions of IE while using HTML5?

Below is the HTML code that I am working with: <section class="first-content-top"> <img src="images/img-diner.png" /> <h1>Menu</h1> </section> <section class="first-content-middle"> <article class="m ...

Adjusting the columns of two tables when one table is held in place

My dilemma involves managing two tables: In the scenario, Table 1 remains fixed in place serving as a header that is always visible. Meanwhile, Table 2 acts as the data table. I am not a fan of fixed widths for my tables; I prefer them to dynamically adj ...

Can anyone advise on the proper way to import CSS within a React component?

I'm currently working on a React component named Comp1 and I've included a CSS file within it like so: import "./style.css"; Within the style.css file, I'm using the following line: @import "https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi ...

What steps should I take to transform this into a :nth-child css selector that is dynamic?

Currently, I am designing a diamond grid system using CSS. I am facing an issue where I need to shift the 5th block to the left and then every 7th subsequent block after that (12th, 19th, 26th, etc). Is there a way to create a dynamic nth selector for th ...

The pagination feature in vue router is malfunctioning and not functioning as intended

I have successfully implemented a query parameter for changing pages: getProducts(){ this.$router .push({ name: 'products', query: { page: this.page, }, }) .catch(() => {}) ...

Learn how to center content and stretch a column using Vuetify frameworks

Looking for a layout with 2 columns of equal height and centered content vertically? Here's how to achieve it using Vuetify! Check out the code snippet below: <div id="app"> <v-app> <v-row align="center"> ...

Adjust the width and height of the span to encompass more than just the content within it

I'm struggling to apply height and width to empty spans using CSS, but the span only fills its content <div class="container"> <div id="widgets-container"> <span class="widget" name="widget1" style="background-col ...

Eliminate the display of Last Modified date and file Size in mod_autoindex

Recently, while developing a file storage webpage for my website, I successfully implemented mod_autoindex for my Apache server. However, I now face the challenge of removing the Last Modified and Size fields from the table. I am hopeful that there is a w ...

What could be causing the issue with axios when trying to send a PUT request for a Laravel API call?

Need help with my Vue component request: submit() { axios .put(`/api/posts/${this.slug}`, this.fields, { headers: { "content-type": "multipart/form-data" }, }) .then((res) => { // s ...