>[success] # v-if 和v-for ~~~ 1.v-if 的优先级比 v-for 更高,这意味着 v-if 将没有权限访问 v-for 里的变量: ~~~ ~~~html <!-- 因为v-if 的优先级高此时v-for 产生的todo还不存在 因此会报错 --> <li v-for="todo in todos" v-if="!todo.isComplete"> {{ todo }} </li> ~~~ * 可以这么修改 ~~~html <template v-for="todo in todos"> <li v-if="!todo.isComplete"> {{ todo }} </li> </template> ~~~ ~~~ 1.上面的写法依旧不是一个很好的做法,建议在使用计算属性,在计算属性中将需要的值进行过滤掉 ~~~ [v-if 与 v-for 的优先级对比非兼容](https://v3.cn.vuejs.org/guide/migration/v-if-v-for.html#%E6%A6%82%E8%A7%88)