Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
}
});
Source by vuejs.org #
 
PREVIOUS NEXT
Tagged: #vue #watch
ADD COMMENT
Topic
Name
6+2 =