el-image 的关闭事件

3 篇文章 0 订阅
1 篇文章 0 订阅
<el-image style="width: 100%; height: 100%" :src="item.imgUrl" :preview-src-list="[item.imgUrl]"
  @click.stop="handlePreviewImg(item)" />
// 预览照片
async handlePreviewImg(item) {
  this.viewData.power = item.power;
  this.viewData.pictureId = item.id;
  this.viewData.departmentName = sessionStorage.getItem('departmentName');
  this.viewData.userName = sessionStorage.getItem('loginName');
  this.viewData.userId = sessionStorage.getItem('userId');
  let res = await ViewApi.saveViewDetail(this.viewData);
  if(res && res.code == '10000' && res.resultFlag) {
    // 图片浏览成功
  }
  this.$nextTick(() => {
    let domImageView = document.querySelector(".el-image-viewer__mask"); // 获取遮罩层dom
    let closeEle = document.querySelector(".el-image-viewer__close"); // 获取遮罩层关闭按钮dom
    if (!domImageView || !closeEle) {
      return;
    }
    domImageView.addEventListener("click", () => {
      console.log('点击了遮罩层');
      // 页面刷新
      this.handleImagePage(this.activeObj.layers, this.activeObj.id);
    });
    closeEle.addEventListener("click", () => {
      console.log('点击了关闭按钮');
      // 页面刷新
      this.handleImagePage(this.activeObj.layers, this.activeObj.id);
    });
  });
}
el-image组件中的事件包括点击事件关闭事件。在前面的引用中提到了一种方法来监听el-image的点击事件。通过在el-image的父级元素上监听点击事件,当点击关闭按钮或蒙层时,可以执行相应的操作。具体做法是通过在dom元素上添加监听器,在点击事件中判断点击的位置是否是关闭按钮或蒙层,并执行相应的逻辑操作。这种方法可以实现el-image关闭功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [element-ui新版本el-image点击事件导致body标签滚动条消失的一个坑](https://blog.csdn.net/jsxg2009/article/details/115244562)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [el-image图片放大后的关闭事件](https://blog.csdn.net/m0_48076809/article/details/129111642)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [详解elementuiel-image-viewer(图片查看器)](https://download.csdn.net/download/weixin_38717156/12937805)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值