代码之家  ›  专栏  ›  技术社区  ›  mikemaccana

vscode警告第一个参数未使用,但我使用后面的参数

  •  1
  • mikemaccana  · 技术社区  · 6 年前

    // catch 404 and forward to error handler
    app.use(function(request, response, next) {
        next(createError(404))
    })
    

    vscode抱怨:

    已声明“request”,但从未读取其值。

    next 如果我也移除了 request

    有没有办法让vscode不发出警告,并且仍然让e-route工作?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Matt Bierner    6 年前

    只需在未使用的参数名称前面加下划线:

    app.use(function(_request, _response, next) {
        next(createError(404))
    })
    

    VS代码的内置未使用变量检查现在将忽略以 _