[Vuejs]-Computed property – price netto and price per one item

2👍

Instead of computed you want methods:

methods: {
  priceNet(price) {
    return price / 1.23
  },
  pricePerItem(price, amount) {
    return price / amount
  }
},

then, in your html update the bindings:

<tr v-for="(element, index) in amount">
    <td>{{ element.amount }}</td>
    <td>{{ priceNet(element.price) | curr }}</td>
    <td>
      {{ element.price | curr }}
      {{ pricePerItem(element.price, element.amount) | curr }}
    </td>
</tr>

Updated fiddle:

https://jsfiddle.net/75Lk2tpe/1/

Leave a comment