Vue中,methods中的方法之间的互相调用。

  •  this.$options.methods.test2();

  • new Vue({
        el: '#app',
      data: {
          test:111,
      },
      methods: {
          test1:function(){
                alert(this.test)
            },
            test2:function(){
                alert("this is test2")
                alert(this.test) //test3调用时弹出undefined
            },
            test3:function(){
                this.$options.methods.test2();//在test3中调用test2的方法
            }
      }
    })
    

     

你可能感兴趣的:(vuejs)