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

Using Vanilla JavaScript and VueJS to smoothly scroll back to the top of a div when a button is clicked

I have a VueJS-based app that features a multistep form with a next button. You can check out the functioning of the app here: My current challenge is ensuring that once the user clicks the next button, the top of the following question becomes visible. I ...

Reducing the size of CSS classes and IDs

I am searching for a way to automatically compress classes and ids in an .html file. This specific file is generated through a sequence of gulp commands. I attempted to use the Munch command line application, but it had adverse effects on the file by elimi ...

Is there a way to identify the specific property name in the view that is causing the error message 'Cannot read property '0' of null'?

When developing, I often encounter this error that I can't seem to trace back to its source or pinpoint the specific variable involved: Cannot read property '0' of null <div id="vueApp" > ... {{probablyNotArray[0]}} ... </div> ...

Vue.js: Can someone provide guidance on retrieving a list of component instances for a slot?

Looking to access the vue instances of a group of slot components, specifically needing access to the key or id of the slot components in order to preserve their state during the beforeUpdate and updated hooks. The component template is structured as foll ...

Retrieve information from deeply nested JSON and showcase using Vue-Multiselect

My goal is to fetch data from the server and present it in Multiselect using nested JSON, which can be done through Vue-Multiselect. Once displayed, I should have the ability to add new tags as needed, essentially updating the data. While I can display o ...

I am having trouble retrieving a nested element from a JSON object within a Vue component

I have a JSON dictionary that looks like this: { "result_list":[ { "device_id":"1", "latest_device_point":{ "device_point_id":"6erDcYJtPkm58k81f07-0F", "dt_server":"2020-08-12T22:21:16.135338Z", ...

Reactive map not triggering Vue computed() function

Having a reactive relationship with an initially empty map: const map = reactive({});, I also have a computed property that checks if the map contains a key named "key": const mapContainsKeyComputed = computed(() => map.hasOwnProperty("key")). However, ...

Having difficulty inserting an image with style="background-image:url(' ')" in Rails from the database

Hi everyone! I am new to both Rails and Stack Overflow, and I would really appreciate it if someone could guide me here. I am currently working on a test site that resembles a personal blog. It's mainly for showcasing one user's portfolio. In t ...

I encountered an issue while attempting to download a zipped folder using an AXIOS get request, as the folder appeared

I have developed an application in NodeJs for the backend and VueJS for the frontend. I am attempting to download a zip file that is generated within the app on the frontend using the code snippet below: const downloadZIP = () => { AXIOS_REQUEST( ...

The toggling feature seems to be malfunctioning as the div section fails to display

I'm facing an issue with my Django project while working on a template. I want to toggle the visibility of a div element between hiding and showing, but the function I used isn't working for some reason. I borrowed the function from a different t ...

Troubleshooting: Why is the Vue search feature in v-data-table not functioning properly

My issue involves using computed values to populate my v-data-table, and I am struggling to resolve the search functionality. Additionally, I would like to re-enable column sorting if possible. Below is the code for my v-Data-Table: <v-data-table ...

What causes the discrepancy between 1px and 0px padding on floating divs in various web browsers?

Take a look at this HTML example - the only variation is padding-top:0px; vs padding-top:1px; However, in the second example, the div is shifted by a completely different amount? <div style="clear: both; margin:0px; padding-top:0px; border: 0px"> ...

What is the best way to ensure that this <span> maintains a consistent width, no matter what content is placed inside

So here's the deal, I've got some dynamically generated html going on where I'm assigning 1-6 scaled svgs as children of a . The span is inline with 2 other spans to give it that nice layout: I want these "boxes" to all be the same width be ...

Is there a way to prevent this <li> tag from collapsing?

Yellow is currently the color of <li> elements that are children of <ul>. However, if I apply either a float or display property to the <li> or <ul>, the appearance changes. The pink colored <li> elements which are nested ins ...

Conceal the vertical scrollbar while allowing horizontal scrolling to remain enabled

I'm attempting to create a layout with HTML/CSS where there is a div that can be scrolled vertically and horizontally, but I only want the horizontal scrollbar to be visible. The vertical scrolling should be done using the mouse wheel while the horizo ...

What is the best method to adjust the width of the <option> tag within the <select> tag using CSS?

<!DOCTYPE html> <html> <head> <title>Page Title</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="s ...

Achieving consistent width for flex items in each row

Can I ensure that all flex items have the same width? Currently, my code looks like this: .video-container { background-color: blue; min-height: 90vh; display: flex; flex-wrap: wrap; } .video { flex: 1 0 25%; } <div class="video-contain ...

Declaration of Character Encoding in CSS3

Do I need to include a character encoding declaration in CSS3? When I add the @charset "utf-8"; declaration, Visual Studio's CSS3 validation displays a warning. Can anyone offer some guidance on this issue? ...

Compilation of CSS by Webpack resulting in peculiar class identifiers

Currently, I am using webpack for developing a React app with a NodeJS backend. I've encountered an issue with styling the app as webpack seems to be interfering with my CSS, causing changes in class names. For example, in my base.css file, I have d ...

Placing an Image in the Right Corner Using jQuery Mobile

I am currently developing a mobile app and I need to align three images one below the other at the right corner next to some text. Any suggestions would be greatly appreciated. Thank you in advance. Below is my code snippet: <div> <ul data-r ...