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' }) } }