[Vuejs]-Assign a value in Vue.js onchange of input

0👍

if i understand you correctly,, you want form.price_vat to change, every time you change form.price_user by typing inside the input.

you can do this using watch. just add the below your methods in vue:

watch:{
   'form.price_user':function():{
      this.form.price_vat += 1
    },
}

so in this code, you update the value of form.price_vat by 1 every time the form.price_user changes. you can do anything inside the function of watch.

the complete vue part will be :

data(){
  return:{
     form:{
       price_vat :'',
       price_user : '',
     }
  }
},

methods:{},

watch:{
       'form.price_user':function():{
          this.form.price_vat += 1
        },
}

Leave a comment