1 try{ 2 list.forEach((i) => { 3 if(!i.title){ 4 throw ‘BreakT‘ 5 } 6 if (i.option_type == 0 || i.option_type == 1) { 7 i.option.forEach(v => { 8 if (!v && v !== 0) { 9 throw ‘BreakV‘; 10 } 11 }) 12 } 13 }) 14 }catch(e){ 15 uni.showToast({ 16 icon: ‘none‘, 17 title: e == ‘BreakT‘ ? ‘您有题目未添加标题,请检查‘ :‘您有选项未设置问题,请检查‘ 18 }) 19 return false; 20 }
for循环直接 break
原文:https://www.cnblogs.com/zjt-blogs/p/12581166.html