Reputation: 55
I'm passing the value of object as props into my "data" studentId
inside the form
data() {
return {
form: new Form({
studentId: []
})
};
},
In my method
, the classlists has initial value, which are the id of students
insertScore() {
let students = this.classlists; //<---this is my props
let element = [];
let s = [];
for (let index = 0; index < students.length; index++) {
element = students[index].id;
}
}
//id: 7
//id:29
//id:30
What i need is to make my classlists ids
to be an array and store it into my studentId
like studentId = [7,29,30]
, but what i'm getting when i console.log is separate Ids
Upvotes: 0
Views: 1189
Reputation: 5249
I'm not sure if this is what are you trying to achieve but if you want new array with only specific property from the classlist
, this should do work.
insertScore() {
const elements = this.classlists.map(e=>e.id)
}
Upvotes: 1