【问题标题】:How to output debug statements to console in Visual Studio Code如何在 Visual Studio Code 中将调试语句输出到控制台
【发布时间】:2017-08-20 17:20:47
【问题描述】:

如何从 .js 方法写入控制台?

console.log 在 Visual Studio Code 的“控制台”选项卡中没有显示任何内容

这是我的方法的一个例子

_onPressItem = (index) => {
    console.log("Property Finder >> Pressed row: "+index);
};

当我按下 ListView 中的某个项目时会触发此事件。如果我通过 XCode 运行它,我会看到上面的 console.log 行打印在 XCode 中。但是如果我在 VSCode 中调试它,我根本看不到 console.log 行被打印出来。

我的步骤: 1.在VSCode中打开我的项目 我的 VS Code 已经安装了 react-native 工具

  1. Cmd+P然后输入命令Debug: Start Debuging(这是一个可用的命令,我只是选择它)

  2. 我的应用程序启动,DEBUG CONSOLE 选项卡显示一些行,但我的console.log 命令中没有显示行

【问题讨论】:

  • 显示一些实际代码。
  • 也许 react-native 正在抓取控制台对象?在导入 react-native 之前尝试将控制台对象分配给您自己的 var。只是一个想法。

标签: javascript react-native visual-studio-code console.log


【解决方案1】:

我补充说:

"outputCapture": "std"

我的调试启动配置和console.log 语句在“DEBUG CONSOLE”选项卡中工作。

或者:

"console": "integratedTerminal" 

在“终端”标签中显示console.log

【讨论】:

    【解决方案2】:

    Debug > Start Debugging F5 并在DEBUG CONSOLE 处查看输出

    【讨论】:

    • 即使我添加了 react-native 工具的扩展,仍然没有看到任何 console.log 语句输出到 DEBUG CONSOLE
    【解决方案3】:

    我也有同样的问题。

    我在浏览器中打开(“type”:“vscode-edge-devtools.debug”)在配置中。

    在浏览器中,如果我按 f12 并转到“控制台”选项卡,那似乎就是 console.log 正在写入的位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      • 2023-04-09
      • 2011-01-25
      • 2015-08-12
      相关资源
      最近更新 更多