0👍
✅
From vue v-for with v-if
When they exist on the same node, v-if has a higher priority than v-for. That means the v-if condition will not have access to variables from the scope of the v-for
You are using the v-for
with v-if
correctly. The problem is with :key
being put on the conditional blocks.
Either way, something will render in the div, you have two possible outcomes and the key should be on the line with the v-for
. You should not conditionally render :key
attribute.
// 1
<div>
<div>
Hi,my name is john
</div>
</div>
// 2
<div>
<div>
This person is private
</div>
</div>
Source:stackexchange.com