Answer the question
In order to leave comments, you need to log in
How to add Object to Object on the fly?
I have an Object that looks like a section structure ( an expanded Object ). From this Object, I pull out data on selects with dependencies.
It is necessary to copy completely its 0 element into this Object when clicking on the button. That is, what should happen .
I ask you to help in solving this issue, examples, links, documentation of functions or methods through which you can wrap it.
If you need any clarification, please ask
Answer the question
In order to leave comments, you need to log in
If I have a problem only in copying an object, then it is usually solved through
In this case
Or do you need something more tricky?
Spread syntax will help you
, the code would look something like this:
this.config.internalChannel.channels = {
...this.config.internalChannel.channels,
1: this.config.internalChannel.channels[0]
}
The task was to add an object to an object on the fly for data reactivity on VueJs.
The task was solved by an asynchronous function via this.$set();
You can read about it in the documentation , paragraph Asynchronous update queue
I can't guarantee that this option is correct, but it works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question