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

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

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

关键代码

html 复制代码
<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" />
javascript 复制代码
 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;
    },
}
相关推荐
小贺要学前端13 小时前
【无标题】
前端·javascript·vue·技术趋势
IT教程资源C21 小时前
(N_141)基于springboot,vue网上拍卖平台
mysql·vue·前后端分离·拍卖系统·springboot拍卖
dy171721 小时前
el-table表头上下显示内容
javascript·vue.js·elementui
IT教程资源C1 天前
(N_144)基于微信小程序在线订餐系统
mysql·vue·uniapp·前后端分离·订餐小程序·springboot订餐
合作小小程序员小小店1 天前
web网页开发,在线短视频管理系统,基于Idea,html,css,jQuery,java,springboot,mysql。
java·前端·spring boot·mysql·vue·intellij-idea
aiguangyuan2 天前
Vue 3.0 源码解读
vue·前端开发
一只小阿乐4 天前
vue3 使用v-model开发弹窗组件
javascript·vue.js·elementui
humors2214 天前
前端开发案例(不定期更新)
前端·vue.js·elementui·ruoyi·若依
阿奇__4 天前
el-table有固定列时样式bug
vue.js·elementui·bug
IT教程资源D4 天前
[N_144]基于微信小程序在线订餐系统
mysql·vue·uniapp·前后端分离·订餐小程序·springboot订餐