element-plus [Component] menu组件存在子菜单激活时,初始化会触发open事件,原Element UI版本仅在点击该菜单时触发,故存在表现不一致问题

s71maibg  于 5个月前  发布在  其他
关注(0)|答案(5)|浏览(60)

Bug Type: Component

Environment

  • Vue Version: 3.2.47
  • Element Plus Version: 2.2.32
  • Browser / OS: Chrome/110.0.0.0
  • Build Tool: Vite

Reproduction

  • el-menu
  • el-menu-item
  • el-menu-item-group

Element Plus Playground

Steps to reproduce

  1. 查看element plus示例代码,可见在刷新时触发open方法,打印 open 1 ['1'] , 链接见最小复现环境的链接
  2. 查看element ui示例代码,链接见 https://codepen.io/Tiylor/pen/LYJZoBL, 可见初始化不会触发open方法。
  3. 所以存在表现不一致的情况,烦请关注下,感谢!

What is Expected?

期望组件在行为上与element ui保持一致,即不再初始化时触发open事件

What is actually happening?

初始化时触发open事件

Additional comments

(empty)

hpcdzsge

hpcdzsge1#

https://element-plus.run/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8ZWwtcm93IGNsYXNzPVwidGFjXCI+XG4gICAgPGVsLWNvbCA6c3Bhbj1cIjEyXCI+XG4gICAgICA8aDUgY2xhc3M9XCJtYi0yXCI+RGVmYXVsdCBjb2xvcnM8L2g1PlxuICAgICAgPGVsLW1lbnVcbiAgICAgICAgZGVmYXVsdC1hY3RpdmU9XCIxLTJcIlxuICAgICAgICBjbGFzcz1cImVsLW1lbnUtdmVydGljYWwtZGVtb1wiXG4gICAgICAgIEBvcGVuPVwiaGFuZGxlT3BlbkZ1blwiXG4gICAgICAgIEBjbG9zZT1cImhhbmRsZUNsb3NlXCJcbiAgICAgID5cbiAgICAgICAgPGVsLXN1Yi1tZW51IGluZGV4PVwiMVwiPlxuICAgICAgICAgIDx0ZW1wbGF0ZSAjdGl0bGU+XG4gICAgICAgICAgICA8ZWwtaWNvbj48bG9jYXRpb24gLz48L2VsLWljb24+XG4gICAgICAgICAgICA8c3Bhbj5OYXZpZ2F0b3IgT25lPC9zcGFuPlxuICAgICAgICAgIDwvd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aWNvbj48c2V0dGluZyAvPjwvZWwtaWNvbj5cbiAgICAgICAgICA8c3Bhbj5OYXZpZ2F0b3IgRm91cjwvc3Bhbj5cbiAgICAgICAgPC9lbC1tZW51LWl0ZW0+XG4gICAgICA8L2VsLW1lbnU+XG4gICAgPC9lbC1jb2w+XG4gIDwvZWwtcm93PlxuPC90ZW1wbGF0ZT5cblxuPHNjcmlwdCBsYW5nPVwidHNcIiBzZXR1cD5cbmltcG9ydCB7XG4gIERvY3VtZW50LFxuICBNZW51IGFzIEljb25NZW51LFxuICBMb2NhdGlvbixcbiAgU2V0dGluZyxcbn0gZnJvbSAnQGVsZW1lbnQtcGx1cy9pY29ucy12dWUnXG4gIGNvbnN0IGhhbmRsZU9wZW5GdW4gPSAoa2V5OiBzdHJpbmcsIGtleVBhdGg6IHN0cmluZ1tdKSA9PiB7XG4gIGNvbnNvbGUubG9nKCdvcGVuJyxrZXksa2V5UGF0aClcbn1cbmNvbnN0IGhhbmRsZU9wZW4gPSAoa2V5OiBzdHJpbmcsIGtleVBhdGg6IHN0cmluZ1tdKSA9PiB7XG4gIC8vY29uc29sZS5sb2coa2V5LCBrZXlQYXRoKVxufVxuY29uc3QgaGFuZGxlQ2xvc2UgPSAoa2V5OiBzdHJpbmcsIGtleVBhdGg6IHN0cmluZ1tdKSA9PiB7XG4gIC8vY29uc29sZS5sb2coa2V5LCBrZXlQYXRoKVxufVxuPC9zY3JpcHQ+XG4iLCJpbXBvcnRfbWFwLmpzb24iOiJ7XG4gIFwiaW1wb3J0c1wiOiB7fVxufSIsIl9vIjp7fX0=

nfeuvbwi

nfeuvbwi2#

当我把default-active 动态绑定的时候,在页面F5刷新的时候,会router.afterEach 进行菜单获取,同时此时给default-active进行赋值,因默认只能打开一个二级菜单,此时default-active 会由空字符串改变成对应时间菜单key值,存中菜单由关闭到展开过程,会触发open事件,如果default-active是一个静态字符串是不回出此问题的

rur96b6h

rur96b6h3#

错误类型:Component

环境

  • 版本: 3.2.47
  • 元素加版本: 2.2.32
  • 浏览器/操作系统: Chrome/110.0.0.0
  • 构建工具: Vite

再生产

相关组件

  • el-menu
  • el-menu-item
  • el-menu-item-group

复制链接

元素加游乐场

重现步骤

  1. 查看元素加上示例代码,可以在刷新时触发打开方法、打印 open 1 ['1'] 、链接看到最小恢复环境的链接
  2. 查看element ui示例代码,链接见 https://codepen.io/Tiylor/pen/LYJZoBL, 可见初始化不会触发open方法。
  3. 所以存在表现不一致的情况,烦请关注下,谢谢!

预期是什么?

期望组件在行为上与element ui保持一致,即不再初始化时触发open事件

到底发生了什么?

初始化时触发open事件

补充评论

(空的)

当我把default-active动态绑定的时候,在PageF5刷新的时候,会router.afterEach进行菜单获取,同时此时给default-active进行属性,因默认只能打开一个二级菜单,此时default -active 会由空字符串改变成对应时间的菜单键值,存中菜单由关闭到展开过程,会触发open事件,如果default-active是一个静态字符串则不会出现此问题的

sd2nnvve

sd2nnvve4#

我也遇到同样的问题,很致命,请问解决了吗

iq0todco

iq0todco5#

Has this issue been fixed?

相关问题