天天看點

在事件中嵌套事件時return的作用

對于return的解釋: return語句終止函數的執行,并傳回一個指定的值給函數調用者。

個人了解:return是對目前函數的一個傳回,是以并不會影響外部的函數,
各自是各自并不牽扯。單如果是語句中通return就可以起到一個中斷的作用      
handelel() {
 console.log("handelel運作了");
 return
}
handle() {
  handelel()
  console.log("handle")
}

hanle()      
console.log("handelel運作了");
console.log("handle")      
//return 來進行中斷,使函數不要進行那麼多的判斷,提高效率
async handleStepClick(index) {
      if (this.active === 0) {
        await this.$refs['customerInfoDom'].whetherPassValidator();
        if (this.passValidator) {
          this.active = index;
          this.passValidator = false;
        }
        return;
      }
      if (this.active === 1) {
        this.active = index;
        return;
      }
      if (this.active === 2) {
        this.active = index;
        return;
      }
    },      

繼續閱讀