v-if v-for 谁的优先级高

源码解析地址:https://github.com/vuejs/vue.git

求证:

 

从源码文件夹src/compiler/codegen/index.js 60行

结论:

  1. v-for的优先级高于v-if 

      2. 如果同时出现v-for v-if的话无论判断条件成立于否都会执行一遍v-for循环

      3. 我们可以把判断条件提取出来写在循环外面 节省性能

猜你喜欢

转载自www.cnblogs.com/frankxing/p/12759850.html