对于return的解释: return语句终止函数的执行,并返回一个指定的值给函数调用者。
如果仅仅是return:则返回 undefined。
个人理解: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;
}
},