Why v-if and v-for of vue are not recommended to be used together

Why v-if and v-for of vue are not recommended to be used together

When making ifjudgments, v-forit is better v-ifto judge first

Final conclusion: v-forthe priority ratio v-ifis high

in conclusion

  1. Never use v-ifand v-foron the same element at the same time, resulting in a waste of performance (each rendering will first loop and then perform conditional judgment)
  2. To avoid this situation, nest in the outer layer template(page rendering does not generate domnodes), perform v-if judgment at this layer, and then perform v-for loop inside
<template v-if="isShow">
    <p v-for="item in items">
</template>

Guess you like

Origin blog.csdn.net/weixin_50975172/article/details/130918341