I have an array in data()
:
data() { return { list: [], } }, methods: { pushData() { this.list.push({name:'yorn', age: 20}); } }
Now I want to push to the 'list' array in the following format, the key is info
:
list [ info [ { name:yorn, age: 20 } ] ]
I'm new to vuejs and javascript, so I need everyone's help. Please give me your opinion. Thanks
Try changing the
pushData
method to have thedata
parameterCalling method
The above expected result is not a valid
JSON
. It should look like below:Working Demonstration: