Suppose I have an array of objects in my vue state as shown below:
[ {name: "Daniel", default: false}, {name: "Ross", default: true}, {name: "Rachel", default: false}, {name: "Joey", default: false} {name: "Monica", default: true} {name: "Gunther", default: true} ]
On my web page, all these names are already displayed in the list. What I want to display on the web page is as follows:
From the above example, I think it's pretty clear what I want to achieve. What is the easiest way to achieve this in vue?
Try using the
compulated
attribute. Check the code snippet belowYou can use Array.map to iterate over all array elements and generate the result you want