A
A
akchl12021-10-28 05:16:01
Vue.js
akchl1, 2021-10-28 05:16:01

How to get the parameter from the array obtained from the selected checkboxes?

An array is created consisting of the data of the selected checkboxes, the data of one element includes: "title", "cost", "id".
you need to get cost from the resulting array, in order to further calculate the total cost of all selected elements,
please tell me how to get cost and throw it into a new array, consisting only of cost values.

the source code is here, but I don’t know how to run vue in this editor
https://jsfiddle.net/h6cdn9ys/1/

this is how the result looks like
617a080d17183516470475.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-10-28
@akchl1

computed: {
  summary() {
    return (this.choosenSize?.cost ?? 0) + this.choosenTopping.reduce((acc, n) => acc + n.cost, 0);
  },
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question