【vue3 element-plus使用el-sub-menu折叠后图标消失问题 】

VUE3 图标消失

有子菜单的图标折叠后消失
在这里插入图片描述
代码如下

<el-menu
            router
            :default-active="this.$route.path"
            class="el-menu-vertical-demo"
            background-color="#333744"
            text-color="#fff"
            active-text-color="#409BFF"
            :unique-opened="true"
            :collapse-transition="false"
            :collapse="isCollapse">
          <!--使用v-if语句进行判断有无children菜单,确定一级菜单是否需要下拉功能-->
          <template v-for="item in arrType">
          <el-sub-menu
              text-color="#fff"
              :index="1"
              :key="item.key"
              v-if="subtitleIsExist(item)">
            <!--一级菜单在submenu中为下拉状态-->
            <template #title>
              <component :is="item.icon" style="width: 20px;height: 20px;margin-right: 5px"></component>
              <span>{{item.title}}</span>
            </template>
            <!--二级菜单再次进行v-if判断是否显示二级菜单-->
            <template v-for="item2 in item.children" :key="item2.key">
              <el-menu-item
                :index="item2.path"

                >
                <component :is="item2.icon" style="width: 20px;height: 20px;margin-right: 5px"></component>
                <span>{{item2.title}}</span>
              </el-menu-item>
            </template>
          </el-sub-menu>

          <!--一级菜单使用v-else在不在submenu中为非下拉状态-->
          <el-menu-item :index="item.path" v-else>
            <component :is="item.icon" style="width: 20px;height: 20px;margin-right: 5px"></component>
            <template #title>
              <span>{{item.title}}</span>
            </template>
          </el-menu-item>
          </template>
        </el-menu>

解决办法

更改el-sub-menu的display为grid

.el-sub-menu{
  display: grid;
}

解决后
在这里插入图片描述

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值