为什么这个函数会从JSLint收到警告消息?

问题描述 投票:0回答:1

我有一个完美的功能,但我仍然收到来自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'。代码中是否存在明显错误,或者我应该忽略该消息?

javascript html5-canvas jslint
1个回答
1
投票
function undoActionClick() {
    if (history.length <= 1) {
        return;
    }
    history.pop();
    contextTmp.putImageData(history[history.length - 1], 0, 0);
    updateHistorySelection();
}

这应该没问题,这不是你的代码的错误,但是JSLint的一个规则是错误的。

有关docs的更多信息

© www.soinside.com 2019 - 2024. All rights reserved.