Sum all properties value in object Using Vuejs

0
()

Sum all properties value in object Using Vuejs

In this Post We Will Explain About is Sum all properties value in object Using Vuejs With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Calculating sum of repeated elements in Vue.js Example

In this post we will show you Best way to implement Total count of object values, hear for How to create Computed property of sub object with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  Php Static Variables & Methods

Include External Libs

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.min.js"></script>

Free Live Chat for Any Issue

index.html

<div id="app">
   <ul>
        <li v-for="product in productList">
            {{ product.name}}: {{ product.price * product.qty}}
        </li>
        <li>Total: {{ Sum }}</li>
    </ul>
</div>

index.js

new Vue({
    el:'#app',
    data: {
        productList: [
            { name: 'Mobile', qty: 2, price: 20 },
            { name: 'Laptop', qty: 3, price: 150 },
            { name: 'DVD', qty: 1, price: 80 },
            { name: 'Cable', qty: 5, price: 40 }
        ]
    },
    computed: {
        Sum(){ return this.productList.reduce( (Sum, product) => product.price * product.qty + Sum  ,0);},
    }
})

style.css

ul {list-style:none;}
li:last-child { border-top:2px solid;border-bottom:4px double;}

Total count of object values

Read Also:  Get all eloquent query log using Laravel 7/6 example

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

Download

I hope you have Got What is How to create Computed property of sub object And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

Read Also:  global variable for all controller and views in Laravel

How useful was this post?

Click on a star to rate it!