欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue組件watch屬性實(shí)例講解

 更新時(shí)間:2017年11月07日 08:48:58   作者:匿名的girl  
這篇文章主要為大家詳細(xì)介紹了vue組件watch屬性實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue組件watch屬性的具體代碼,供大家參考,具體內(nèi)容如下

<!doctype html>
<html>
 <head>
 <meta charset="UTF-8">
 <title>wacth屬性</title>
 <script src="js/vue.js"></script>
 </head>
 <body>
 <div id="container">
  <p>{{msg}}</p>
  <my-component></my-component>
 </div>
 <script>
  Vue.component("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(){
    //當(dāng)數(shù)據(jù)發(fā)生變化、執(zhí)行的操作
       console.log("數(shù)據(jù)改變");
    },
    myPhone:function(){
     console.log(this.myPhone);
    }
   }
  })
  new Vue({
   el:"#container",
   data:{
    msg:"Hello VueJs"
   }
  })
 </script>
 </body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論