vue element ui el-table单元格里面显示多张图片点击并放大

本文介绍如何在表格单元格中展示多张图片,并通过Element UI的Popover组件实现点击图片进行放大的功能。具体步骤包括使用v-for循环渲染图片以及对接口返回的数据进行处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

效果图:

一个单元格里面显示三张图片,并且点击图片可以放大。

1.将图片v-for渲染出来,具体上代码

 <el-table-column label="发布图片" align="center" prop="postImages" width="400px">
        <template slot-scope="scope" >
          <span v-for="(item2,index2) in scope.row.postImages" >
            <el-popover
              placement="right"
              width="400"
              trigger="click">
               <img  :src="item2" width="400px" height="400px" >
            <img  slot="reference" :src="item2" width="100px" height="100px" >
          </el-popover>
       <!--    这个是实现点击图片放大功能的代码-->
          </span>
        </template>
</el-table-column>

注:el-popover的属性 

 2.单元格里能够展示多张图片,需要在请求的接口里面做处理

getList() {
      this.loading = true;
      listPosts(this.queryParams).then(response => {
        this.total = response.total;
        for(let index in response.rows){
          response.rows[index].postImages=response.rows[index].postImages.split(',')//后端返回的是以,分隔的字符串,将其转化成字符串数组。
        }
        this.postsList = response.rows;
        this.loading = false;
      });
    },

以上两步,就可以实现上面的功能。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿wei程序媛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值