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

[vue] 11. 请问 v-if 和 v-show 有什么区别 #402

Open
qiilee opened this issue Oct 8, 2019 · 2 comments
Open

[vue] 11. 请问 v-if 和 v-show 有什么区别 #402

qiilee opened this issue Oct 8, 2019 · 2 comments
Labels

Comments

@qiilee
Copy link
Member

qiilee commented Oct 8, 2019

答案:

v-show 指令是通过修改元素的 display 的 CSS 属性让其显示或者隐藏

v-if 指令是直接销毁和重建 DOM 达到让元素显示和隐藏的效果

@qiilee qiilee added the VUE label Oct 8, 2019
@Xgj22
Copy link

Xgj22 commented Apr 25, 2023

v-show 有着更高的初始渲染消耗,v-if 有更高的切换消耗,需要频繁切换的适合用 v-show ,不需要频繁切换的适合 v-if

@tnnevol
Copy link

tnnevol commented May 14, 2024

v-if 会销毁组件或者重新初始化组件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants