轮播切换

在这里插入图片描述

<div class="file-pic">
      <div class="left">
        <img v-if="getFileExtension(currentImage.filePath)!='mp4'" @click="handleImg" id="aabccb" :src="currentImage.fileUrl" alt="Image">
        <video v-else @click="handleVideo" id="aabb" controls style="width:100%;height:100%;background-color: black;" :src="currentImage.fileUrl"></video>
      </div>
      <div class="right">
        <div class="top">
          <i class="el-icon-caret-top" @click="prevImage"></i>
        </div>
        <div class="right-pic">
          <div v-for="(item,indexS) in images" :key="indexS" class="pic-img" :class="indexS==currentIndex?'active':''">
            <img v-if="getFileExtension(item.filePath)!='mp4'" :src="item.fileUrl" />
            <video v-else style="width:100%;height:100%;background-color: black;" :src="item.fileUrl"></video>
          </div>
        </div>
        <div class="bottom">
          <i class="el-icon-caret-bottom" @click="nextImage"></i>
        </div>
      </div>
    </div>
import screenfull from "screenfull";
 data() {
    return {
      images: [
        {
          fileUrl:
            "http://192.168.110.36:9000/air/任务附件测试图片_1702019545459.png",
          filePath: "/air/任务附件测试图片_1702019545459.png",
        },
        {
          filePath: "air/任务测试视频文件_1699251185315.mp4",
          fileUrl:
            "http://192.168.110.36:9000/air/任务测试视频文件_1699251185315.mp4",
        },
       
      ],
      currentIndex: 0,
    };
  },
  created() {
  },
  computed: {
    currentImage() {
      return this.images[this.currentIndex];
    },
  },
  watch: {
    currentIndex(newVal, oldVal) {
      var targetDiv = document.getElementsByClassName("right-pic")[0];
      var height = targetDiv.scrollHeight / this.images.length;
      targetDiv.scrollTop = height * this.currentIndex;
    },
  },
   methods: {
   //点击全屏展示
    handleVideo() {
      let element = document.getElementById("aabccb");
      screenfull.toggle(element);
    },
    handleImg() {},
    prevImage() {
      this.currentIndex =
        (this.currentIndex - 1 + this.images.length) % this.images.length;
    },
    nextImage() {
      this.currentIndex = (this.currentIndex + 1) % this.images.length;
      console.log("下一页:", this.currentIndex, this.images.length - 1);
    },
    //截取后缀
    getFileExtension(filename) {
      var parts = filename.split(".");
      return parts[parts.length - 1];
    },
  },
.file-pic {
  display: flex;
  align-items: center;
  grid-column-gap: 18px;
  .left {
    width: 550px;
    height: 380px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    width: 192px;
    height: 380px;
    border: 1px solid #e1e6f0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    .top {
      width: 100%;
      height: 19px;
      background: red;
      text-align: center;
      .el-icon-caret-top {
        font-size: 18px;
        color: #c0c4cc;
        cursor: pointer;
      }
      .el-icon-caret-top:hover {
        color: #3885fd;
      }
    }
    .right-pic {
      display: flex;
      flex-direction: column;
      // justify-content: center;
      align-items: center;
      overflow: auto;
      flex: 1;
      .pic-img {
        flex-shrink: 0;
        width: 150px;
        height: 100px;
        margin: 5px 0;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .active {
        border: 2px solid #3885fd;
      }
    }
    .bottom {
      width: 100%;
      height: 19px;
      background: red;
      text-align: center;

      .el-icon-caret-bottom {
        font-size: 18px;
        color: #c0c4cc;
        cursor: pointer;
      }
      .el-icon-caret-bottom:hover {
        color: #3885fd;
      }
    }
  }
}
  • 7
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值