在我的仪表板中,我正在显示带有一些内容(标题和正文)的卡片,并且数据来自后端 api,并且该数据存储在 DisplayNotes.vue 中存在的 notes[] 数组中,并且每张卡片都包含一些图标,如果用户点击任何卡片TRASH 图标(例如:第 4 张卡片删除图标),特定 clickedTrashIcon 卡片数据应传递给 DeleteNote.vue 组件,并将数据存储在 DeleteNote 内部名为 Trash 的数组中。 vue 组件,请帮我解决这个问题
DeleteNote.vue
<template>
<div class="Trash-section">
<div v-for="item in Trash" :key="item.id" class="container note">
<div class="delete-content">
<h5>{{item.title}}</h5>
<p>{{item.body}}</p>
<div class="icons Trash-icons">
<i class="fas fa-trash"></i>
<i class="fas fa-trash-restore"></i>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'DeleteNote',
data() {
return {
Trash: [{
id: 1,
title: 'Fundoo',
body: 'Trash component'
},
{
id: 2,
title: 'second',
body: 'trash'
},
{
id: 2,
title: 'second',
body: 'trash'
},
{
id: 2,
title: 'second',
body: 'trash'
},
{
id: 2,
title: 'second',
body: 'trash'
},
]
}
}
}
</script>
<style scoped>
.icons {
margin-top: 12.2%;
margin-left: 5%;
opacity: 0.9;
}
.icons .fa-trash-restore {
padding-left: 25px;
}
.icons .fa-trash:hover {
font-size: 20px;
cursor: pointer;
}
.Trash-section {
margin-top: 5%;
display: flex;
align-items: flex-start;
flex-wrap: wrap;
align-content: space-around;
gap: 10px;
}
.container {
width: 22%;
margin-top: 5%;
margin-left: 18%;
margin-right: -15%;
box-shadow: 5px 5px 10px #e0dede;
float: left;
}
.container:hover {
box-shadow: 6px 6px 10px rgb(199, 199, 199);
}
h5 {
font-size: 20px;
font-weight: 400;
font-family: 'Times New Roman', Times, serif;
padding-left: 10px;
}
p {
font-size: 18px;
width: 90%;
height: 60px;
font-family: 'Times New Roman', Times, serif;
width: 100%;
padding: 7.5px 10px;
}
.Trash-icons {
visibility: hidden;
}
.note:hover .Trash-icons {
visibility: visible;
}
</style>
DisplayNotes.vue
<template>
<div class="carddisplay-section">
<div v-for="note in notes" :key="note.id" id="blur" class="container note">
<div @click="toggle(note.id)" class="card-content">
<h5>{{note.title}}</h5>
<p>{{note.body}}</p>
</div>
<div class="import-icons">
<icons class="imported-icons note-icons" />
<button v-if="flag" class="card-button" type="button" @click="handlesubmit();Togglebtn();">Close</button>
</div>
</div>
<div id="popup">
<UpdateNotes :cardId="clickedCard" :cardContent="cardContent" />
</div>
</div>
</template>
<script>
import service from '../service/User'
import icons from './icons'
import UpdateNotes from './UpdateNotes.vue'
export default {
name: 'DisplayNotes',
components: {
icons,
UpdateNotes
},
data() {
return {
flag: true,
notes: [{
id: 1,
title: 'Fundoo',
body: 'unlimited notes..'
}, ],
clickedCard: '',
cardContent: {},
}
},
methods: {
Togglebtn() {
this.flag = !this.flag;
},
async handlesubmit() {
service.userDisplayNotes().then(response => {
this.notes.push(...response.data);
})
},
toggle(id) {
var blur = document.getElementById('blur');
blur.classList.toggle('active');
this.clickedCard = id;
// this.card.content = this.notes.filter((note) => note.id === id);
var popup = document.getElementById('popup');
popup.classList.toggle('active');
},
}
}
</script>
<style lang="scss">
@import "@/styles/DisplayNotes.scss";
</style>
icons.vue
<template>
<div class="footer">
<i class="fas fa-bell"></i>
<i class="fas fa-user"></i>
<i class="fas fa-palette"></i>
<i clss="fas fa-image"></i>
<i class="fas fa-archive"></i>
<!-- <i class="fas fa-ellipsis-v"></i> -->
<i class="fas fa-trash"></i>
</div>
</template>
<style scoped>
.footer i {
opacity: 0.9;
position: relative;
}
.footer .fa-bell {
margin-top: 5px;
margin-left: 10px;
}
.footer .fa-user {
margin-top: 5px;
margin-left: 40px;
}
.footer .fa-palette {
margin-top: 5px;
margin-left: 40px;
}
.footer .fa-image {
margin-top: 5px;
margin-left: 40px;
}
.footer .fa-archive {
margin-top: 5px;
margin-left: 40px;
}
/* .footer .fa-ellipsis-v {
margin-top: 5px;
margin-left: 40px;
} */
.footer .fa-trash {
margin-top: 5px;
margin-left: 40px;
cursor:pointer;
}
</style>
main.js
import Vue from 'vue'
import App from './App.vue'
// import 'bootstrap/dist/css/bootstrap.min.css'
// import '@/assets/css/main.css'
//vuelidate
import vuelidate from 'vuelidate'
import 'bootstrap/dist/css/bootstrap.min.css'
import router from './router'
import './service/axios'
import store from './store';
// import ('./src/Styles/Forget.css')
Vue.config.productionTip = false
Vue.use(vuelidate)
new Vue({
router,
render: h => h(App),
}).$mount('#app')