下拉的点击出现以及隐藏

12 篇文章 0 订阅

在这里插入图片描述

<template>
  <div class="app-container road-sprinkler-workload">
    <div class="window-box">
      <div class="equipmentName">
        <div class="video-tag-list">
          <div class="video-tag-btn" v-for="(item,index) in equipmentType.slice(0,2)" :key="index">{{item}}</div>
          <div class="video-tag-arrow">
            <i id="textI" class="cameraName iconfont icon-xiangxia"></i>
          </div>
        </div>
      </div>
      <div class="video-tag-list video-drop video-drop-down">
        <div class="video-tag-btn" v-for="(item1,index1) in equipmentType.slice(2,equipmentType.length)" :key="index1">{{item1}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      equipmentType: ["道", "域", "业"],
      videoDrop: false,
    };
  },
  created() {
    this.info();
  },
  methods: {
    info() {
      this.$nextTick(() => {
        if (this.equipmentType.length > 2) {
          let arrow = document.getElementsByClassName("video-tag-arrow");
          let down = document.getElementsByClassName(`video-drop`);
          let downBtn = down[down.length - 1];
          let arrowBtn = arrow[arrow.length - 1];
          // 判断下拉箭头是否被点击过
          this.videoDrop = false;
          downBtn.style.display = "none";
          arrowBtn.style.background = "#fff";
          if (arrow.length) {
            if (!arrowBtn.onclick) {
              arrowBtn.onclick = () => {
                this.videoDrop = !this.videoDrop;
                if (this.videoDrop) {
                  downBtn.style.display = "grid";
                  arrowBtn.style.background = "#f90000";
                  arrowBtn.style.transform = "rotate(180deg)";
                  arrowBtn.style.color = "#fff";
                } else {
                  downBtn.style.display = "none";
                  arrowBtn.style.background = "#fff";
                  arrowBtn.style.color = "#909399";
                  arrowBtn.style.transform = "rotate(360deg)";
                }
              };
            }
          }
        }
      });
    },
  },
};
</script>
<style scoped>
.window-box {
  position: relative;
  background-size: 100% 100%;
}
.type {
  display: flex;
  height: 32px;
  line-height: 32px;
}
.typeItem {
  background: #006eff;
  color: #fff;
  border-radius: 50000px;
  padding: 0 14px;
  margin-left: 10px;
}
.equipmentName {
  height: 40px;
  line-height: 40px;
  color: #606266;
  font-size: 14px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.equipmentTypeName {
  background: #f90000;
  border-radius: 50000px;
  display: block;
  height: 26px;
  line-height: 26px;
  padding: 0 12px;
  color: #fff;
  margin-left: 14px;
}
.video-tag-list {
  display: flex;
  align-items: center;
  justify-content: right;
  width: 194px;
}
.video-tag-btn {
  min-width: 74px;
  height: 26px;
  background: #f90000;
  border-radius: 13px;
  color: #ffffff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
}
.video-tag-arrow {
  width: 18px;
  height: 18px;
  background: #f90000;
  border-radius: 3px;
  border: 1px solid #d8dce6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.video-tag-arrow i {
  font-size: 7px;
}
.video-tag-arrow:hover {
  background: #f90000 !important;
}
.video-tag-arrow:hover i {
  color: #fff;
}
.video-tag-arrow i {
  margin-top: 1px;
}
.video-drop-down {
  position: absolute;
  z-index: 24;
  left: 16px;
  top: 50px;
  width: 198px;
  background: #ffffff;
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  display: none;
  grid-template-columns: repeat(2, 1fr);
  box-sizing: border-box;
  padding: 18px 10px 10px 18px;
}
.video-drop-down .video-tag-btn {
  margin-bottom: 10px;
}
</style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值