-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
第 147 题:v-if、v-show、v-html 的原理是什么,它是如何封装的? #307
Comments
v-if:当隐藏结构时该结构会直接从整个dom树中移除; v-show:当隐藏结构时是在该结构的style中加上display:none,结构依然保留。 |
v-if: Watcher监听数据变化,然后,render函数生成VNode对象,patch方法对比新旧VNode, DOM Diff 算法修改真正的DOM元素 |
v-if会调用addIfCondition方法,生成vnode的时候会忽略对应节点,render的时候就不会渲染; |
所以在使用v-html的时候可能会存在XSS攻击的漏洞,被植入可执行的脚本 |
如何根据v-if的原理写一个v-permission,要求切换权限时节点可以被删除,也可以在删除后被添加回来 |
https://stackoverflow.com/questions/43003976/a-custom-directive-similar-to-v-if-in-vuejs |
No description provided.
The text was updated successfully, but these errors were encountered: