Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You make one more calculated property, by analogy with sum - an array of titles of marked elements:
selectedServices() {
return this.services.reduce((acc, n) => (n.checked && acc.push(n.title), acc), []);
},
<ul>
<li v-for="n in selectedServices">{{ n }}</li>
</ul>
selectedServices() {
return this.services.filter(n => n.checked);
},
<ul>
<li v-for="n in selectedServices">{{ n.title }}</li>
</ul>
sum() {
return this.selectedServices.reduce((acc, n) => acc + n.cost, 0);
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question