[Vuejs]-Manipulate data in vuejs and post it in input field

0👍

Here’s a working example. Might be a bit overkill, but I only had few minutes to write the code 🙂

var app = new Vue({
  el: '#app',
  data: {
    dm: 1,
    dmtoeur: 0.51,
  },
  methods: {
    calculateDmToEur: function() {
      this.dmtoeur = (Math.round(((this.dm / 1.95583) + 0.00001) * 100) / 100);
    },
  },
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script>

<div id="app">
  <input type='number' v-model='dm' @click="calculateDmToEur()" @keyup="calculateDmToEur()">
  <input type='number' v-model='dmtoeur'>
</div>

Leave a comment