Answer the question
In order to leave comments, you need to log in
How to track the change of the main object?
Hello.
I have an array of objects:
products: [
{id: 1, name: 'prod 1'},
{id: 2, name: 'prod 2'},
{id: 3, name: 'prod 3'},
]
order: {
id: 1,
date: '2019',
products: [
{product_id: 1, count: 3},
{product_id: 2, count: 5},
{product_id: 3, count: 0},
]
}
let orderProducts = products.map(product => {
return {
product_id: product.id,
count: productCount(product)
}
})
Answer the question
In order to leave comments, you need to log in
Can be obtained through computed or through getters (if using vuex)
computed: {
orderWithProducts() {
const order = this.order;
return {
...order,
products: this.products.map(product => ({
product_id: product.id,
count: productCount(product)
}))
};
},
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question