G
G
Gorynn2019-06-15 00:07:33
JavaScript
Gorynn, 2019-06-15 00:07:33

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

3 answer(s)
A
Alex Karo, 2019-06-15
@gorynn

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?

2
2perca, 2019-06-15
@2perca

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]
}

G
Gorynn, 2019-06-17
@Gorynn

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 question

Ask a Question

731 491 924 answers to any question