简体   繁体   中英

Vue.js update subtotal in array

After some research i find this post what have an example about how to manage a complex array in Vue.js https://forum.vuejs.org/t/vuex-best-practices-for-complex-objects/10143/2

I have create this jsbin ( https://jsbin.com/jocezud/5/edit?html,js,output ) to make some test but i´m stuck at this point. I want to make some totals based in the checked topics:

A) When the checkbox of each Topic is checked the price value must be copied to the subTotal value.

B) Also every user must have the userTotal updated with the sum of the subTotal of the checked Topics .

Here is a capture about my goal.

在此处输入图片说明

Thanks in advance

Finally i get it working with also a Final total and a Reset feature.

Here is the actual working version ( https://jsbin.com/jocezud/12/edit?html,js,output )

Anyway i think there must be a better way to, in this case run some calculations of data in arrays when a array value change happens, right?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM