vue 关于在方法内添加回调函数的方法

58 阅读1分钟

当调用一个方法后需要调用另外一个方法方式. arg为常规参数 func为回调 //方法

functionName(arg,func) {
 getAction(this.url.list, params)
        .then((res) => {
          if (res.success) {
            this.dataSource = res.result.records
            this.ipagination.total = res.result.total
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
          this.loading = false
        }).then(() => {
          func(xxx)
        })
}

//调用方式

  this.functionName(1, ()=> {
  //执行回调
        })