Skip to content
Advertisement

How to merge a object to a array object in vuejs

I have a api response.data

JavaScript

And my component .vue

JavaScript

I want merge placeholder object to result after api response

Advertisement

Answer

Result is actually a list. You can use the destructuring assignment

JavaScript

to prepend the placeholder.

To use concat you must wrap the placeholder in a list.

JavaScript

to achieve the same result in a “more conservative way”.

Or you can use the Object.unshift as suggested by @kemicofa ghost.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement