vue渲染富文本数据中图片点击显示大图——单张图片


 

<div class="textarea" v-html="detailInfo.text" @click="showImg($event)"></div>

<!-- 富文本图片放大 -->
<div class="imgDolg" v-show="imgPreview.show">
  <i class="el-icon-close" id="imgDolgClose" @click.stop="imgPreview.show = false"></i>
  <el-image ref="imgDolg" class="img" :src="imgPreview.img" fit="cover"></el-image>
</div>

 

data() {
  return {
    // 图片放大
    imgPreview: {
       img: '',
       show: false,
    },
  }
}

methods: {
  // 图片点击放大
        showImg(e) {
            if (e.target.tagName == 'IMG') {
                this.imgPreview.img = e.target.src
                this.imgPreview.show = true
            }
        },
}

 

//富文本图片放大
.imgDolg {
    width: 100vw;
    height: 100vh;
    position: fixed;
    z-index: 9999;
    background-color: rgba(140, 134, 134, 0.6);
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    #imgDolgClose {
        position: fixed;
        top: 35px;
        cursor: pointer;
        right: 7%;
        font-size: 50px;
        color: white;
    }
    .img {
        width: 70%;
        max-height: 90%;
    }
}
.img-hidden {
    width: 0 !important;
    height: 0 !important;
    // visibility:hidden;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM