【问题标题】:In Visual Studio Code, how to pass arguments in launch.json在 Visual Studio Code 中,如何在 launch.json 中传递参数
【发布时间】:2020-01-13 07:51:33
【问题描述】:

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

【问题讨论】:

    标签: node.js visual-studio-code command-line-arguments


    【解决方案1】:

    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"]
            }
        ]
    }
    

    【讨论】:

    • @eigenfield 您是否尝试过使用 Visual Studio Code 或 Kotlin 提交错误报告?
    • 只是为了澄清 args 数组,"args": ["key=value", "key=value"]
    • @AwaisNasir 是对 Kotlin 的建议吗?还是一般?在实践中,我使用了简单的字符串而不是键值对。
    • @JonathanBenn 我不了解 kotlin,这是通用解决方案,对我来说,键值对解决方案有效,而不是简单的字符串
    • 好的,您的里程数可能会有所不同。对于 Node.JS,我使用了一个简单的字符串(不是键值对),没有任何问题。在任何情况下,无论 in 字符串是什么,输入始终是一个字符串。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2018-05-19
      • 2020-01-24
      • 2018-02-16
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 2019-08-06
      相关资源
      最近更新 更多