A
A
Andrej Sharapov2019-08-09 11:55:54
Vue.js
Andrej Sharapov, 2019-08-09 11:55:54

How to pass the value of one component to another?

Good afternoon!
Sandbox #1:

There are 2 components here: a general list and a selected component (modal type). Opened by clicking on the arrows.
By clicking on the arrow, component No. 2 opens, into which information from component No. 1 is transferred.
Now the problems:
I need to add a class to the picture on click on this arrow or picture fullImage: false,. Added to component number 1, everything works.

@click="fullImage = !fullImage, $emit('select', f)" :class="{ fullImage }"
OK.
In the second component, adding @click="fullImage = !fullImage, $emit('close')" should remove this class, but it doesn't work.
Tell me what I missed and how to fix it?
Sandbox #2:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-08-09
@Madeas

There is a selected property on the parent component - use it, pass it to the list, and assign a class depending on whether the list item is equal to the currently selected one.
https://jsfiddle.net/cfLk1jdu/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question