我有一个完美的功能,但我仍然收到来自JS Lint的警告信息。
function undoActionClick() {
if (history.length <= 1) return;
history.pop();
contextTmp.putImageData(history[history.length - 1], 0, 0);
updateHistorySelection();
}
这是警告信息:Expected '{' and instead saw 'return'
。代码中是否存在明显错误,或者我应该忽略该消息?
function undoActionClick() {
if (history.length <= 1) {
return;
}
history.pop();
contextTmp.putImageData(history[history.length - 1], 0, 0);
updateHistorySelection();
}
这应该没问题,这不是你的代码的错误,但是JSLint
的一个规则是错误的。
有关docs的更多信息