zoukankan      html  css  js  c++  java
  • vue隐藏列表点击当前列表项,显示列表详情,其它列表项隐藏

     

    <div
                  v-for="(item, index) in newList"
                  class="floor-board-contbox-sub-t"
                >
                  <div class="contbox-sub-t-f">
                    <div
                      :class="item.isShow ? 'corner-l' : 'corner'"
                      @click="showItem(item, index)"
                    ></div>
                    <!-- <div :class="item.isShow ? 'corner-l' : 'corner'"></div> -->
                    <div>abcidf</div>
                    <div>{{ item.name }}</div>
                    <div>在线</div>
                  </div>
                  <div class="contbox-sub-t-s" v-if="item.isShow">
                    {{ item.name }}
                  </div>
                </div>
              </div>
    list: [
            {
              name: "name1",
              id: 1,
              delivery: false,
            },
            {
              name: "name3",
              id: 2,
              delivery: false,
            },
            {
              name: "name4",
              id: 3,
              delivery: true,
            },
            {
              name: "name5",
              id: 4,
              delivery: true,
            },
            {
              name: "name6",
              id: 5,
              delivery: false,
            },
            {
              name: "name7",
              id: 6,
              delivery: true,
            },
          ],
    computed: {
        newList() {
          return this.list.map((item) => {
            this.$set(item, "isShow", false);
            return item;
          });
        },
      },
     showItem(item, index) {
          const newStatus = item.isShow;
          this.list.forEach((item) => {
            item.isShow = false;
          });
          item.isShow = !newStatus;
        },
    .contbox-sub-t-f {
                display: flex;
                width: 100%;
                justify-content: space-between;
                align-items: center;
                padding: 0 20px;
                height: 44px;
                .corner {
                  width: 0px; /*  宽高设置为0,很重要,否则达不到效果 */
                  height: 0px;
                  border: 10px solid #fff;
                  border-bottom-color: transparent; /* 设置透明背景色 */
                  border-top-color: transparent;
                  border-right-color: transparent;
                }
                .corner-l {
                  width: 0px; /*  宽高设置为0,很重要,否则达不到效果 */
                  height: 0px;
                  border: 10px solid #fff;
                  border-bottom-color: transparent; /* 设置透明背景色 */
                  border-left-color: transparent;
                  border-right-color: transparent;
                }
              }
              .contbox-sub-t-s {
                display: flex;
                width: 100%;
                background: red;
              }
  • 相关阅读:
    网络设备snmp配置syslog方法。
    Oracle19c安装手册Windows及mysql-oracle转换
    Oracle11g--hxss安装
    VMWare ESXI 6.5 的部署及简单使用的说明
    windos下redis的启动与安装
    二、fidder 和 python结合进行 get post 请求发送
    一、fidder工具使用
    Python学习二《数据类型介绍》
    Python学习一《基础规范》
    Charles设置为代理服务
  • 原文地址:https://www.cnblogs.com/Byme/p/14700739.html
Copyright © 2011-2022 走看看