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;
    },
}
相关推荐
IT教程资源C2 小时前
(N_144)基于微信小程序在线订餐系统
mysql·vue·uniapp·前后端分离·订餐小程序·springboot订餐
合作小小程序员小小店9 小时前
web网页开发,在线短视频管理系统,基于Idea,html,css,jQuery,java,springboot,mysql。
java·前端·spring boot·mysql·vue·intellij-idea
aiguangyuan12 小时前
Vue 3.0 源码解读
vue·前端开发
一只小阿乐3 天前
vue3 使用v-model开发弹窗组件
javascript·vue.js·elementui
humors2213 天前
前端开发案例(不定期更新)
前端·vue.js·elementui·ruoyi·若依
阿奇__3 天前
el-table有固定列时样式bug
vue.js·elementui·bug
IT教程资源D3 天前
[N_144]基于微信小程序在线订餐系统
mysql·vue·uniapp·前后端分离·订餐小程序·springboot订餐
是梦终空5 天前
vue下载依赖报错npm ERR node-sass@4.14.1 postinstall: `node scripts/build.js`的解决方法
javascript·npm·vue·node-sass·vue依赖
陈陈小白5 天前
npm run dev报错Error: listen EADDRINUSE: address already in use :::8090
前端·npm·node.js·vue
韩立学长5 天前
【开题答辩实录分享】以《证劵数据可视化分析项目设计与实现》为例进行答辩实录分享
python·信息可视化·vue