1 In vue, which has a higher priority: V-if or v-for?

Source to find the answer in compiler/codegen/index. The js test

<p v-for="item in items" v-if="isShow">{{item.title}}</p>

<temple v-if="isShow">
	<p v-for="item in items" >{{item.title}}</p>
</temple>
Copy the code

Answer: 1. V – for priority than v – if, the compiler/codegen/index. The js code to prove that 2, 64-66 in the code. If it happens at the same time, each render will execute a loop to determine the condition first, which will be unavoidable in any case, wasting performance 3. To avoid this, nest a layer around the periphery, do the judgment on the outer layer, and then do the V-if loop 4 inside. Another situation is when the judgment condition is in a loop, and it’s inevitable that for and if are written together

<p v-for="item in items" v-if="item.isShow">{{item.title}}</pCopy the code