0👍
Calling a method inside template will make an infinite rendering, in order to get the sum of your item just define a computed property that does that for you based on the items :
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<div v-for="(v,i) in list">
{{v}}
</div>
<b>
{{total}}
</b>
</div>
<script>
new Vue({
el: "#app",
data: {
list: [1, 2, 3, 4, 5, 6],
tmp: 0
},
computed: {
total() {
return this.list.reduce((acc, curr) => {
return acc += +curr;
}, 0)
}
}
});
</script>
Source:stackexchange.com