SoFunction
Updated on 2025-04-05

Vue component watch attribute example explanation

This example shares the specific code of the watch attribute of the vue component for your reference. The specific content is as follows

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>wacthproperty</title>
 <script src="js/"></script>
 </head>
 <body>
 <div >
  <p>{{msg}}</p>
  <my-component></my-component>
 </div>
 <script>
  ("my-component",{
   data:function(){
    return {
     myInput:"",
     myPhone:123456
    }
   },
   template:`
    <div>
     <input type="text" v-model="myInput"/>
     <input type="text" v-model="myPhone"/>
     <span>{{myInput}}</span>
    </div>
   `,
   watch:{
    myInput:function(){
    //When the data changes, the operation performed     ("Data Change");
    },
    myPhone:function(){
     ();
    }
   }
  })
  new Vue({
   el:"#container",
   data:{
    msg:"Hello VueJs"
   }
  })
 </script>
 </body>
</html>

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.