我遇到了一个错误,表示有非法的continue语句。 我有一个单词列表,用于表单验证,问题是它将一些子字符串与保留字匹配,因此我创建了另一个干净的单词数组进行匹配。如果匹配到一个干净的单词就继续,否则如果匹配到保留单词就提示用户。
$.each(resword,function(){
$.each(cleanword,function(){
if ( resword == cleanword ){
continue;
}
else if ( filterName.toLowerCase().indexOf(this) != -1 ) {
console.log("bad word");
filterElem.css('border','2px solid red');
window.alert("You can not include '" + this + "' in your Filter Name");
fail = true;
}
});
});
=== false
),它就会继续执行。因此,你可以只是使用return;
,它会返回未定义的值,这将起到 continue 的作用。 - Bob Fincheimer