我开发了一个页面displaybooks.vue,它负责显示书籍。响应来自后端api,基于它将在我的ui页面中显示的数据,在我的ui页面中,每张卡都包含两个按钮(添加到包和添加到包),当用户单击任何卡的添加到包按钮时,它将隐藏添加到包,并仅在特定单击的卡上显示添加到包按钮,请帮助我完成此操作。 DisplayBooks.vue
```
</div>
<div class="AddedBag">
<button class="big-btn">Added to Bag</button>
</div>
</div>
</div>
`DisplayBooks.scss`
@import "colors";
.carddisplay-section {
display: flex;
align-items: flex-start;
flex-wrap: wrap;
align-content: space-around;
gap: 10px;
}
.card:hover{
box-shadow:0.6px 0.6px 0.6px 0.6px rgb(173, 206, 206);
}
.card {
margin-top: 55px;
margin-left: 110px;
background:$pink;
// width: 235px;
// height: 275px;
width: 235px;
height: 315px;
background: $pale_white 0% 0% no-repeat padding-box;
border: 1px solid $border_clr;
border-radius: 3px;
opacity: 1;
}
.image-section {
width: 233px;
height: 172px;
background: #F5F5F5 0% 0% no-repeat padding-box;
border-radius: 2px 2px 0px 0px;
opacity: 1;
}
img{
margin-left: 67px;
margin-top: 17px;
width: 105px;
height: 135px;
opacity: 1;
border:none;
}
.title-section {
text-align: left;
font: normal normal normal 14px/19px Roboto;
letter-spacing: 0.2px;
color: $light_black;
opacity: 1;
margin-left: 20px;
margin-top: 3px;
width: 130px;
height: 19px;
text-transform: capitalize;
}
.author-section {
text-align: left;
font: normal normal normal 13px/13px Roboto;
letter-spacing: 0px;
color: $light_grey;
opacity: 1;
width: 123px;
height: 13px;
margin-left: 20px;
margin-top: 7px;
}
.price-section {
text-align: left;
font: normal normal bold 12px/16px Roboto;
letter-spacing: 0px;
color: $light_black;
opacity: 1;
margin-left: 20px;
height: 16px;
margin-top: 26px;
display: flex;
justify-content: flex-start;
}
label {
text-decoration-line: line-through;
font: normal normal normal 10px/13px Roboto;
letter-spacing: 0px;
color: $light_grey;
opacity: 1;
width: 36px;
height: 13px;
margin-top: 2.5px;
margin-left: 1em;
}
button[type="submit"] {
border: none;
padding-left: 65px;
background: none;
font-size: 15;
}
.button-groups{
display:flex;
margin-top:8px;
}
.AddBag{
background: #A03037 0% 0% no-repeat padding-box;
border-radius: 2px;
opacity: 1;
width: 93px;
height: 29px;
margin-left:20px;
color: #FFFFFF;
text-transform: uppercase;
opacity: 1;
font-size: small;
}
.wishlist{
margin-left:4px;
color: #FFFFFF;
text-transform: uppercase;
opacity: 1;
font-size: small;
border: 1px solid #7c7a7a;
border-radius: 2px;
opacity: 1;
color: #0A0102;
width:93px;
}
.big-btn{
width: 191px;
height: 29px;
margin-left:20px;
background: #3371B5 0% 0% no-repeat padding-box;
border-radius: 2px;
opacity: 1;
color:#FFFFFF;
}
1条答案
按热度按时间axr492tv1#
添加另一个数组,该数组将包含通过单击“添加到书包”按钮添加的图书ID,然后使用
v-if/v-else
要进行条件渲染,请执行以下操作:在模板中:
例子