P
P
pansom2020-02-03 22:48:22
Vue.js
pansom, 2020-02-03 22:48:22

How to create an array of reactive variables?

I apologize right away, I am tongue-tied and can use the wrong words and concepts.

The crux of the matter is this.

I request and receive an array of data, it contains the names of categories and the number of elements inside (which is not the point).
Next, I need to create an accordion for each category and toggle it back and forth.
I can't figure out how to implement this within the framework of 1 component. I have a need for a button that would switch a boolean variable back and forth, but I can’t dynamically create them (an array of variables) so that then they would be reactively processed.

People point your finger to the idiot in the right direction.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
marsdenden, 2020-02-04
@pansom

Array or object? If it's an array, is it possible to convert it to an object? For reactivity use Vue.set

A
Alex, 2020-02-03
@Kozack Vue.js

Convert the data array to a collapse data array in which to add a flag for the elements and open / close on it

I
Igor, 2020-02-04
@IgorPI

When you have received an array of some data, you can always add any property or function or object to each element.
Accordingly, each element can have a handler for something or a boolean property.
In general, the question is not clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question