Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawer组件使用v-if会导致使用v-else的兄弟组件无法渲染。 #3593

Closed
1 task
tangchi695 opened this issue Jan 26, 2021 · 9 comments
Closed
1 task
Labels

Comments

@tangchi695
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.7.2

Environment

vue 2.6.12

Reproduction link

Edit on CodeSandbox

Steps to reproduce

通过v-if切换drawer和其他组件,drawer渲染以后再切换,兄弟组件无法渲染。

What is expected?

能够切换drawer和兄弟组件

What is actually happening?

通过v-if切换drawer和其他组件,drawer渲染以后再切换,兄弟组件无法渲染。

@John60676
Copy link
Member

John60676 commented Jan 29, 2021

请检查自己的代码逻辑哦

你用 show 绑定了 visible prop ,在 onClose 触发时该值被设置为 false。 当 drawer 这个变量第二次被设置为 true 时,show 的值还是 false,这就导致了 a-drawer 无法渲染,从而出现你所说的 “兄弟组件无法渲染。”

@tangchi695
Copy link
Author

请检查自己的代码逻辑哦

你绑定了 visible ,在 onClose 触发时该值被设置为 false。 当 drawer 这个变量第二次被设置为 true 时,visible 的值还是 false

是通过v-if打开drawer以后再关闭,红色的div框不显示了,不是drawer不能再打开了。

@John60676
Copy link
Member

drawer 这个变量为 true 的情况下,红色的 div 如何显示??

请检查自己的代码逻辑!!

@tangchi695
Copy link
Author

drawer 这个变量为 true 的情况下,红色的 div 如何显示??

请检查自己的代码逻辑!!

close方法里面我设置了 drawer变量为false

@John60676
Copy link
Member

请检查自己的代码逻辑哦

你用 show 绑定了 visible prop ,在 onClose 触发时该值被设置为 false。 当 drawer 这个变量第二次被设置为 true 时,show 的值还是 false,这就导致了 a-drawer 无法渲染,从而出现你所说的 “兄弟组件无法渲染。”

你自己先按这个好好捋一下逻辑吧,认真读一下

@tangchi695
Copy link
Author

请检查自己的代码逻辑哦
你用 show 绑定了 visible prop ,在 onClose 触发时该值被设置为 false。 当 drawer 这个变量第二次被设置为 true 时,show 的值还是 false,这就导致了 a-drawer 无法渲染,从而出现你所说的 “兄弟组件无法渲染。”

你自己先按这个好好捋一下逻辑吧,认真读一下

我更新了codesandbox,你再看看我说的是什么意思。。。
你可以在codesandbox里把antd的版本降到一个低版本,比如1.3.0,再看效果有什么不一样。

@John60676
Copy link
Member

John60676 commented Jan 29, 2021

v-if 不要直接加在 a-drawer 组件上面,会引起 vue 的渲染问题。有这样的业务需求的,最好用 div 包裹一层,把 v-if 放在 div

@itmeryn
Copy link

itmeryn commented Jan 29, 2021

v-if 不要直接加在 a-drawer 组件上面,会引起 vue 的渲染问题。有这样的业务需求的,最好用 div 包裹一层,把 v-if 放在 div

可以!

@github-actions
Copy link

github-actions bot commented Feb 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants