el-image
组件来完成。这里来简单记录一下<div class="eventImg_box" @click="choseEventImg(item)">
<el-image
:src="item.eventImagePath"
:preview-src-list="imgList"
class="event_img"
>
</el-image>
<div class="big_img">点击图片放大</div>
</div>
data() {
return {
imgList: [],
};
},
choseEventImg(item) {
this.imgList = [];
this.imgList[0] = item.eventImagePath;
},
事件触发时,记得首先要把数组清空,把imgList等于空数组,然后赋值。
.eventImg_box {
position: relative;
cursor: pointer;
.event_img {
width: 100%;
height: 180px;
}
.big_img {
color: white;
display: none;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 10%;
}
&:hover {
.big_img {
display: block;
}
}
}
下班~