ElemeFE / element

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

[bug report] closeonhashchange parameter update problem #19693

Open tengmaoqing opened 4 years ago

tengmaoqing commented 4 years ago

Element UI version

2.13.0

OS/Browsers version

window 10 / chrome 81

Vue version

2.6.11

Reproduction Link

https://codepen.io/tengmaoqing/pen/LYGWYwq?editors=1111

Steps to reproduce

可以看到先点击按钮1和先点击按钮2. 按钮2 配置了 closeOnHashChange: false,与期望不一致

What is Expected?

不同 $confirm方法的closeOnHashChange 都能生效,应该与配置一致

What is actually happening?

所有$confirm 的 closeOnHashChange 行为都只使用了第一个$confirm的配置。 因为 $confirm 始终使用的是一个 message-box 组件instance,而 closeOnHashChange控制的 hashChange 事件只在mounted中添加,beforeDestroy 中移除。导致了所有$confirm、$alert的closeOnHashChange 配置只有第一个执行的弹窗生效

element-bot commented 4 years ago

Translation of this issue:

Element UI version

2.13.0

OS/Browsers version

window 10 / chrome 81

Vue version

2.6.11

Reproduction Link

https://codepen.io/tengmaoqing/pen/LYGWYwq?editors=1111

Steps to reproduce

You can see that click button 1 first and click button 2 first

Button 2 is configured with closeonhashchange: false, which is inconsistent with the expectation

What is Expected?

Closeonhashchange of different $confirm methods can take effect and should be consistent with the configuration

What is actually happening?

All $confirm's closeonhashchange behavior uses only the first $confirm configuration. Because $confirm always uses a message box component instance, and the hashchange event controlled by closeonhashchange is only added in mounted and removed in beforedestroy. As a result, all closeonhashchange configurations of $confirm and $alert take effect only when the first pop-up window is executed

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.