R
R
Roman2019-01-21 18:34:26
Vue.js
Roman, 2019-01-21 18:34:26

How to dynamically collapse an element in Vue js?

There was a problem. An array of categories and subcategories comes to the component from Vuex, the task is to display all this in the form of a tree.
In the mounted hook of the application itself, I make a request to the server, everything that came in is recorded in the state field. Further, in the component itself, if is a calculated property, in which I receive data from Vuex. As a result, I display it dynamically through a loop. But I can't get the element to collapse and expand when clicking on the icon. I hung an @click handler on the icon in which I change the open property of this category. The property changes (checked in the console) the elements do not react Maybe because of this?
return this.$store.getters.products;

computed properties are cached based on their dependencies

How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-01-21
@roman94

The following helped
When adding new properties to an object, you must either:
Use Vue.set(obj, 'newProp', 123) , or
Completely replace the old object with the new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question