0

I am iterating through items in a checkbox. When I click on an item, it pushes each of those objects into the newItem array. However, I'd like to transform the new data in newItem to just be an array like this: ["age: 55", "age: 25"]... how can I transform the data going into newItem to be shaped like that?

items: [{name:"Billy, age: 55, permission: true}, {name:"Mike, age: 25, permission: false}],
newItem: [],

<v-checkbox v-for="item in items" v-model="newItem"></v-checkbox>

1 Answer 1

1

You could use a computed property called selectedAges based on the newItem property :


computed:{
  selectedAges(){
    return this.newItem.map(item=>{
      return "age: "+item.age;
  
   })
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.