save() { //方法名
let showAlertOnly = false;//设置变量
this.formData.forEach(v=>{
if(v.def&&v.defvalue==''){
showAlertOnly = true;//满足这个if拦截条件变量为true
...继续执行if里的操作
return //return掉
}
})
if (showAlertOnly) {//在上面的循环得出变量是true还是false,true就满足拦截条件就不执行下面的步骤,如果是false就跳过return执行下面的步骤
return; // Exit the function if showAlertOnly is true
}
...被拦截与否之后要执行的步骤
}
02-08
5万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-11
9243
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)