[Vuejs]-V-if statement to compare one parameter and if matches return another parameter within the same object on Vue js

0πŸ‘

v-if in v-for:

<div v-for="item of data">
    <div v-if="item.title === 'condition'">
        {{ item.title }}
    </div>
</div>

0πŸ‘

It is unclear what your condition would be. ie. are you matching duplicates or to another value.

Either way, I would recommend that you use a computed instead of a relying on a v-if. This has numerous benefits, such as cleaner separation of template and logic, makes for easier reading an debugging, and easier to write the filtering logic in js.

Leave a comment