vue-三级菜单栏

示例图:
在这里插入图片描述

nav{
    width: 1080px;
    height: 80px;
    display: flex;
    margin: 15px auto;
    justify-content: space-between;
    align-items: center;
}
nav .right{
    width: 750px;
    display: flex;

}
nav>.right>.aa{
width: 120px;
height: 80px;
line-height: 40px;
padding-top: 50px;
text-align: center;
margin-left: 5px;
border-bottom: 3px transparent solid;
position: relative;
}
nav .right>li:hover{
background-color: rgba(250, 235, 215, 0.559);
}
nav .right .subitem{
    width: 120px;
  display: none; 
  position: absolute; 
  top: 121px;
  left: 0;
  z-index: 1000;
  color: red;
  background-color: rgba(250, 235, 215, 0.559);
}
nav .right .subitem>li{
position: relative;
}
.subitem1{
width: 120px;
position: absolute; 
top: 0;
left: 120px;
z-index: 1000;
color: red;
background-color: turquoise;
display: none;
}
nav .right>li:hover .subitem{
display: block;
}
/*这个代码是生成三角形的代码*/
.aaaa{
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px;
    border-color: transparent transparent transparent grey;
    position: absolute;
    right: 0;
    top: 15px;
}
nav .right .subitem>li:hover .subitem1{
    display: block;
}

数据数从后台渲染的 读者可自行在data里面写 也可自行生成
主要技术需要循环三次 当第三层的时候有的有 有的没有 在第三层里面判断是否存在元素(v-if)

<ul class="right">
                <!-- @mouseenter='show(i)' :class="{light:i===active}"
                    @mouseleave='active=null' -->
                <li v-for='(item,i) in list' class="aa">{{item.Name}}
                    <ul class="subitem">
                        <li v-for='item1 in item.Children' class="bb">
                            {{item1.Name}}
                            <ul class="subitem1">
                                <li v-for='item2 in item1.Children' v-if="item1.Children && item1.Children.length">
                                    {{item1.Name}}j
                                </li>

                            </ul>
                            <div class="aaaa" v-if="item1.Children && item1.Children.length"></div>
                        </li>
                    </ul>
                </li>
            </ul>

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值