We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
做个实验,把v-if和v-for放在一块,输出渲染函数可以判断指令执行的先后顺序。 我们可以用vue2做个demo,在过滤列表的div绑定 v-for="user in users" v-if="user.isActive" 指令,打印其渲染函数:
v-for="user in users" v-if="user.isActive"
ƒ anonymous( ) { with(this){return _c('div',{attrs:{"id":"app"}},_l((items),function(item){return (item.isActive)?_c('div',{key:item.id},[_v("\n "+_s(item.name)+"\n ")]):_e()}),0)} }
源码中找答案 vue2:https://github1s.com/vuejs/vue/blob/HEAD/src/compiler/codegen/index.js#L65-L66 vue3:https://github1s.com/vuejs/core/blob/HEAD/packages/compiler-core/src/codegen.ts#L586-L587
The text was updated successfully, but these errors were encountered:
No branches or pull requests
v-if、v-for的优先级
分析
做个实验,把v-if和v-for放在一块,输出渲染函数可以判断指令执行的先后顺序。
我们可以用vue2做个demo,在过滤列表的div绑定
v-for="user in users" v-if="user.isActive"
指令,打印其渲染函数:注意事项
源码中找答案 vue2:https://github1s.com/vuejs/vue/blob/HEAD/src/compiler/codegen/index.js#L65-L66 vue3:https://github1s.com/vuejs/core/blob/HEAD/packages/compiler-core/src/codegen.ts#L586-L587
The text was updated successfully, but these errors were encountered: