vue中methods互相调用的方法

a:function(goods) {
      this.aa= [];
      this.bb= 0;
      this.cc= 0;
    },
b:function(){
      if(this.bbb!= 0){
        this.aa= [];
        this.bb= 0;
        this.cc= 0;
        this.$message({
          message:'结账成功!',
          type:'success'
        })
      }
    }

  上面代码块里a方法里的代码和b方法里面的代码一模一样,可以使用

this.$options.methods.a.bind(this)();

  来替换

b:function(){
      if(this.bbb!= 0){
        this.$options.methods.a.bind(this)();
        this.$message({
          message:'结账成功!',
          type:'success'
        })
      }
    }

  

posted @ 2018-11-06 14:32  孟祥玉  阅读(5902)  评论(0编辑  收藏  举报