In vue my data looks like this:
data: {
messages: []
}
But the data returned from the api looks like this (array of objects)
messages: Array(1)
0: Object
message: "qwerqwer"
How do I convert a array of objects into an array of arrays?
This will do exactly what you want it to do, but you should try to understand and not just blind copy it:
messages = messages.map(
function(message){
return message.message;
}
);
Read about Array.prototype.map()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.