Cant see any cards
You're right! The issue is likely that the cards aren't visible. Let me fix this by creating a simpler, working version:
working-cards.vue
This simplified version should definitely show the cards! The key changes:
ref() for the cards arrayThe cards should now be visible with:
Try this version and let me know if you can see the cards now!
<template> <div class="card-list"> <div v-for="(card, index) in cards" :key="index" class="card" @click="toggleCard(index)" > <div class="card-header"> <h3>{{ card.title }}</h3> <span class="chevron" :class="{ rotated: expandedIndex === index }" >⌄</span> </div> <transition name="expand"> <div v-show="expandedIndex === index" class="card-body" > <p>{{ card.content }}</p> </div> </transition> </div> </div> </template> <script setup> import { ref } from 'vue' const cards = [ { title: 'Card 1', content: 'This is the detailed content of Card 1.' }, { title: 'Card 2', content: 'This is the detailed content of Card 2.' }, { title: 'Card 3', content: 'This is the detailed content of Card 3.' } ] const expandedIndex = ref(null) function toggleCard(index) { expandedIndex.value = expandedIndex.value === index ? null : index } </script> <style scoped> .card-list { max-width: 600px; margin: 0 auto; } .card { border: 1px solid #ccc; border-radius: 8px; margin-bottom: 12px; padding: 16px; cursor: pointer; background: #fff; transition: box-shadow 0.3s; } .card:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .card-header { display: flex; justify-content: space-between; align-items: center; } .chevron { transition: transform 0.3s ease; display: inline-block; } .chevron.rotated { transform: rotate(180deg); } .card-body { margin-top: 12px; overflow: hidden; } /* Transition */ .expand-enter-active, .expand-leave-active { transition: all 0.3s ease; } .expand-enter-from, .expand-leave-to { max-height: 0; opacity: 0; } .expand-enter-to, .expand-leave-from { max-height: 300px; opacity: 1; } </style>
Your code looks correct! The issue might be that the cards are not visible due to styling or the background. Let me provide a working version with some improvements to ensure the cards are visible:
simple-cards.vue
The cards should now be clearly visible with a clean, professional appearance. Try clicking on any card header to see the smooth expand/collapse animation!
create card colour blue