A
A
Alexander Koregin2020-01-10 16:55:31
Vue.js
Alexander Koregin, 2020-01-10 16:55:31

How to find element by value in Vue.JS?

I want to make my favorite products for the online store. My problem is that I do not know how to access the desired element in the array by value, but I need this in order for the like to be active.

<i v-if="$store.getters.getAllLikedGood[index][item.id_good]" @click="delLikeGood(item.id_good)" class="icon liked fas fa-heart"></i> . //Закрашенный лайк (Должно появляться если нажали на него) 
<i v-bind:class="{ disable: $store.getters.getAllLikedGood[index][item.id_good] }" @click="likeGood(item.id_good)" class="icon-heart far fa-heart"></i> //Не закрашенный лайк (Должно изчезать после нажатия)

getAllLikedGood - Array of Like IDs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2020-01-10
@delphinpro

How to find an element in an array by value in JS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question