Initialize variable with previously declare object value

20 Views Asked by At

I want to initialise selectedElement with the id of the elements object in vuejs.

This is not working:

data() {
 return {
    elements: [
      { id: 0, name: 'Simple elements' },
      { id: 1, name: 'Call to action' },
    ],
    selectedElement: elements[0]
   };
 },
0

There are 0 best solutions below