zoukankan      html  css  js  c++  java
  • vue-cli watch简单用法

    创建一个vue单文件

    <template>
      <div id="test">
        <h4 @click="changeMsg()" id="outputDom">{{msg}}</h4>
      </div>
    </template>
    
    <script>
        export default {
            name: "test",
            data:function(){
              return{
                msg:'test msg'
              }
            },
            watch:{
              msg:function(){
                console.log('msg进行了改变');
              }
            },
            mounted:function(){
            },
            methods:{
              changeMsg:function(){
                this.msg = "改变MSG"
              }
            }
        }
    </script>
    
    <style lang="less">
    </style>
    

      

    这个时候我点击h4标签的时候 便会触发watch中的msg方法

  • 相关阅读:
    @雅礼集训01/13
    @hdu
    @bzoj
    @hdu
    @bzoj
    @雅礼集训01/10
    @codeforces
    @spoj
    @bzoj
    @bzoj
  • 原文地址:https://www.cnblogs.com/MainActivity/p/8953703.html
Copyright © 2011-2022 走看看