自学内容网 自学内容网

element-ui点击文字查看图片预览功能

今天做一个点击文字查看图片的功能,大体页面长这样子,点击查看显示对应的图片
在这里插入图片描述
在这里插入图片描述

引入el-image-viewer,点击的文字时候设置图片预览组件显示并传入图片的地址

关键代码


<el-link v-if="scope.row.fileList.length > 0" type="primary" @click="handleClickImage(scope.row)" :underline="false">查看</el-link>

<el-image-viewer v-if="imageShow" :on-close="() => { imageShow = false; }" :url-list="imageList" />

 components: {
    'el-image-viewer': () => import('element-ui/packages/image/src/image-viewer')
 },
 data() {
    return {
      imageShow: false,
      imageList: []
    };
 },
 methods: {
    handleClickImage(e) {
      this.imageShow = true
      let urls = e.fileList.map(obj => obj.url);
      this.imageList = urls;
    },
}

原文地址:https://blog.csdn.net/frankcheng5143/article/details/142822922

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!