新增超出限制,如何新增一个自动替换一个数据

2桐丶
  • 126

image.png

addCameraList(addCamera) {
      let domain = null;
      if (!addCamera || !addCamera.length) {
        this.cameraList.forEach((vo, idx) => {
          this.removeScreenCamera(idx);
        });
        this.cameraList = [];
        return false;
      }
      if (this.cameraList.length >= this.size) {
        this.$message.info("超过分屏数量限制!");
        在这我想写如果超出限制,新打开视频替换已打开的视频。不知道该怎么写


      }
      if (this.cameraList.indexOf(addCamera[0]) >= 0) {
        this.$message.info("视频已存在!");
        return false;
      }
      this.cameraList.push(addCamera[0]);
      this.$forceUpdate();
      this.$nextTick(() => {
        this.cameraPlay(this.cameraList.length - 1, addCamera[0]);
      });
    },
回复
阅读 404
1 个回答
addCameraList(addCamera) {
      let domain = null;
      if (!addCamera || !addCamera.length) {
        this.cameraList.forEach((vo, idx) => {
          this.removeScreenCamera(idx);
        });
        this.cameraList = [];
        return false;
      }
      if (this.cameraList.indexOf(addCamera[0]) >= 0) {
        this.$message.info("视频已存在!");
        return false;
      }
      this.cameraList.push(addCamera[0]);
      // 个人觉这里比较合适
      if (this.cameraList.length >= this.size) {
        this.$message.info("超过分屏数量限制!");
        //在这我想写如果超出限制,新打开视频替换已打开的视频。不知道该怎么写
        this.cameraList = this.cameraList.slice(-this.size)
      }
      this.$forceUpdate();
      this.$nextTick(() => {
        this.cameraPlay(this.cameraList.length - 1, addCamera[0]);
      });
    },
你知道吗?

宣传栏