[英]Why isn't clearInterval() stopping the setInterval function?
[英]Why isn't this function stopping its parent?
我创建了一个函数,如果给出条件,它将停止其父级:
handleUserSubmit () {
this.userForm.options.hasFormSubmitted = true
if (!this.userForm.options.isFormValid) return
},
handleUpdateUser () {
const fields = this.userForm.schema
this.userInput.buildId = this.user.objectId
this.handleUserSubmit()
// rest of code
}
但是,无论条件如何,其余代码都将运行。 我究竟做错了什么?
将条件返回值移到需要从中返回的函数:
handleUserSubmit () {
this.userForm.options.hasFormSubmitted = true
return !this.userForm.options.isFormValid;
},
handleUpdateUser () {
const fields = this.userForm.schema
this.userInput.buildId = this.user.objectId
if(this.handleUserSubmit()) return;
// rest of code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.