1

I'm trying to figure out how to show job.name if the job.name from jobs is also in anotherArray.

    <li v-for='job in jobs'>
    <template v-if="job.name in anotherArray"
      {{ job.name }}
    </template>
    </li>

note anotherArray is structured the same way as the jobs array. So I want to be checking element.name in anotherArray

How can I do this?

1 Answer 1

2

You can use computed to get list of anotherArrayName, then create a method to check using includes

computed: {
    anotherArrayName() {
        return this.anotherArray.map(item => item.name)
    }
},
methods: {
    isInclude(name) {
        return this.anotherArrayName.includes(name)
    }
}

and in template

 <li v-for='job in jobs'>
    <template v-if="isInclude(job.name)"
      {{ job.name }}
    </template>
</li>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.