在 Visual Studio 代码中,如何在 launch.json 中传递参数

In Visual Studio Code, how to pass arguments in launch.json

在 Visual Studio 代码中,在启动我正在编写的应用程序的 launch.json 文件中,如何添加命令行参数?

documentation所述,您需要使用args属性。 例如

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug App",
            "program": "${workspaceFolder}/main.js",
            "args": ["arg1", "arg2", "arg3"]
        }
    ]
}

我通过这种方式为 python 程序传递参数,它可能适用于 nodejs:

{
    "type": "node",
    "request": "launch",
    "name": "Debug App",
    "program": "${workspaceFolder}/main.js",
    "args": ["--arg1", "value1", "--arg2", "value2"]
}