Created
June 8, 2018 18:12
-
-
Save pacifio/b36e1b832d27a2b5919a9caf42c167f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<ul class="list-group"> | |
<li class="list-group-item"> | |
<span class="item-name"><strong>Name</strong></span> | |
<span class="item-price float-right"><strong>Price</strong></span> | |
</li> | |
<li v-for="(item, index) in items" :key="index" class="list-group-item"> | |
<span class="item-name">{{item.title}}</span> | |
<span class="item-price float-right">{{item.price}}</span> | |
</li> | |
<li class="list-group-item"> | |
<span class="item-name"><strong>Total price</strong></span> | |
<span class="item-price float-right"><strong>{{ grossTotal }}</strong></span> | |
</li> | |
</ul> | |
</template> | |
<script> | |
export default { | |
props:['items'], | |
computed: { | |
grossTotal () { | |
var total = 0; | |
this.items.forEach(item => { | |
var price = item.price.toString().substring(1, item.price.toString().length - 1); | |
console.log(price) | |
total += parseFloat(price) | |
}) | |
return `$${total}` | |
} | |
} | |
} | |
</script> | |
<style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment