简体   繁体   English

如何在 Visual Studio Code 中将调试语句输出到控制台

[英]How to output debug statements to console in Visual Studio Code

How do I write to console from a .js method?如何从 .js 方法写入控制台?

console.log is not showing anything in Console tab in Visual Studio Code console.log未在 Visual Studio Code 的控制台选项卡中显示任何内容

Here is an example of my method这是我的方法的一个例子

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

This is triggered when I press on an item in my ListView.这是在我按下 ListView 中的项目时触发的。 If I run this through XCode, I will see console.log line above printed in XCode.如果我通过 XCode 运行它,我会看到上面用 XCode 打印的console.log行。 But if I debug it in VSCode, I see no console.log line being printed at all.但是如果我在 VSCode 中调试它,我根本看不到console.log行被打印出来。

My Steps: 1. Open my project in VSCode My VS Code has installed react-native tools already我的步骤: 1. 在 VSCode 中打开我的项目 我的 VS Code 已经安装了 react-native 工具

  1. Cmd+P then type command Debug: Start Debuging (it is an available command, I just select it) Cmd+P然后输入命令Debug: Start Debuging (这是一个可用的命令,我只是选择它)

  2. My App starts, DEBUG CONSOLE tab shows some lines but no line from my console.log command is shown我的应用程序启动,DEBUG CONSOLE 选项卡显示了一些行,但没有显示我的console.log命令中的行

I added:我补充说:

"outputCapture": "std"

to my debug launch configuration and console.log statements work in the "DEBUG CONSOLE" tab.我的调试启动配置和console.log语句在“DEBUG CONSOLE”选项卡中工作。

Alternatively:或者:

"console": "integratedTerminal" 

shows console.log in the "TERMINAL" tab.在“终端”选项卡中显示console.log

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

I have the same issue.我有同样的问题。

I'm opening in a browser ("type": "vscode-edge-devtools.debug") in the configuration.我在配置中的浏览器(“type”:“vscode-edge-devtools.debug”)中打开。

In the browser, if I hit f12 and go to the 'console' tab, that appears to be where the console.log is writing to.在浏览器中,如果我按 f12 并转到“控制台”选项卡,这似乎是 console.log 写入的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM