Vue methods中方法之间的调用

delAllOrderList:function(goods) {
      this.tableData = [];
      this.totalCount = 0;
      this.money = 0;
    },
checkout:function(){
      if(this.totalCount != 0){
        this.tableData = [];
        this.totalCount = 0;
        this.money = 0;
        this.$message({
          message:'',
          type:'success'
        })
      }
    }


上面的代码块里,checkout方法里的代码和delAllOrderList里的一模一样,可以使用如下来替换。

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



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



猜你喜欢

转载自forlan.iteye.com/blog/2418358