ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

[Bug Report] NavMenu:The collapse attribute conflicts with the default-openeds attribute #8280

Closed SirM2z closed 6 years ago

SirM2z commented 6 years ago

Element UI version

2.0.4

OS/Browsers version

win 10 / chrome 62

Vue version

2.5.3

Reproduction Link

https://jsfiddle.net/coolmrz/rjr6e8v6/

Steps to reproduce

navmenu component

the collapse property is set to true

and the menu is turned on by default

showing a problem: https://jsfiddle.net/coolmrz/rjr6e8v6/

What is Expected?

Submenus should not be displayed

What is actually happening?

Submenu display

wangfengye commented 6 years ago

can you provide Specific code ?

 <el-menu default-active="1-1">
      <el-submenu index="1">
          <template slot="title">
             <span>菜单1</span>
          </template>
        <el-menu-item index="1-1">选项1</el-menu-item>
        <el-menu-item index="1-2">选项2</el-menu-item>
      </el-submenu>
    </el-menu>

If you set the default - active has a value of el - menu - item 'index, then the el - menu - item's sub - menu will be turn on

SirM2z commented 6 years ago

@wangfengye ,thank you for your reply.

I delete the 'default-active' attribute, but the 'el-menu-item' is also turn on

https://jsfiddle.net/coolmrz/rjr6e8v6/4/

wangfengye commented 6 years ago
:default-openeds="opens" 

The value of default-openeds is submenus which displyed when loaded If you expect Submenus not be displayed, you should remove this attribute

SirM2z commented 6 years ago

This is a bug

wangfengye commented 6 years ago

image image It is you provided demo, i can not find bug

SirM2z commented 6 years ago

I think the default-openeds attribute should has an effect when the collapse attribute is set to false.

but when collapse set to true, the Menu already shows icon only, if sub-menu is also turn on, This does not meet expectations

SirM2z commented 6 years ago

算了 还是讲中文吧。

这仅仅是一个还原现场的demo,因为menu组件肯定是和路由结合的

真实的场景会有这个问题:

当collapse属性设置为true时,菜单是只显示icon的,但切换菜单时,导致路由变动

到新的页面时,就会像上边的demo中一样,那些子菜单显示在页面上

wangfengye commented 6 years ago

刚开始没理解你的意思.是有这个问题. :default-openeds="isCollapse?[]:opens" 我感觉这不算是bug,应该是设计的问题,应该提[Feature Request],增加icon状态不显示子菜单

SirM2z commented 6 years ago

我录了一个屏,刚开始有两个主菜单,第一个主菜单有一个子菜单(微信号),第二个主菜单有两个子菜单(系统人员管理、标签管理)

当点击“标签管理”菜单进入新的页面时,第一个主菜单的“微信号”默认被渲染出来了

至于你说的设置collapse属性时,不能设置default-openeds属性,这不就默认了我的issues标题么:这两个属性有冲突

默认打开菜单属性default-openeds是业务需要,当进入系统时,所有菜单都是打开的,一目了然

但这个时候使用菜单收起功能时,就会出现这个问题,这两个属性不应该是耦合的

当菜单收起(collapse设为true时),default-openeds应该不起作用

SirM2z commented 6 years ago

你上边的解决方法很棒,感谢

不过我还是觉得这个应该在组件层面就解决了

Leopoldthecoder commented 6 years ago

https://github.com/ElemeFE/element/pull/8507/commits/4f7ae51a2b7111b6219c828c472cf33ddea50517