“Vue Watch” Réponses codées

Vue calculé

var vm = new Vue({
  el: '#example',
  data: {
    message: 'Hello'
  },
  computed: {
    // a computed getter
    reversedMessage: function () {
      // `this` points to the vm instance
      return this.message.split('').reverse().join('')
    }
  }
})
Proud Piranha

Vue Watch

var app=
 data(){
   return{
     mobile: "",
     name:{
         Vue.createApp ({
       firstName:
       lastName:
     }
   };
 },
 watch:{
   mobile(newValue, oldValue){
     console.log(newValue);
     if (isNaN(newValue)){
       alert("Enter valid mobile number");
       this.mobile=oldvalue;
     }
     if (newValue.length == 11){
       alert("An OTP has been sent");
     }
   },
   "name.firstName": function (newValue, oldValue){
     console.log(newValue, oldValue);
   },
   name:{
  deep: true,
  handler: function (newValue, oldvalue){
     consolq. log(newValue, oldValue);
}
});
Irfan

Vue Watch


watch: {
  // whenever question changes, this function will run
  question(newQuestion, oldQuestion) {
    // your code
  }
},
  
Suman Majhi

Vue Ajouter un observateur

vm.$watch('person.name.firstName', function(newValue, oldValue) {
	alert('First name changed from ' + oldValue + ' to ' + newValue + '!');
});
Lazy Loris

Réponses similaires à “Vue Watch”

Questions similaires à “Vue Watch”

Plus de réponses similaires à “Vue Watch” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code