<el-image
v-for="(item, index) in certificationImgs"
:key="index"
:src="item" fit="cover"
:preview-src-list="clickcertificationImgs"
title="点击查看图片"
@click="clickPicture(index)"></el-image>
data() {
return {
certificationImgs: [
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
],
clickcertificationImgs: [],//预览图片数组
}
}
//图片点击事件
clickPicture(index) {
this.clickcertificationImgs = [];
this.clickcertificationImgs.push(this.certificationImgs[index])
this.$nextTick(() => {
let domImageView = document.querySelector(".el-image-viewer__mask"); // 获取遮罩层dom
if (!domImageView) {
return;
}
domImageView.addEventListener("click", () => {
// 点击遮罩层时调用关闭按钮的 click 事件
document.querySelector(".el-image-viewer__close").click();
});
});
},