最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to output debug statements to console in Visual Studio Code - Stack Overflow

programmeradmin6浏览0评论

How do I write to console from a .js method?

console.log is not showing anything in Console tab in 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. If I run this through XCode, I will see console.log line above printed in XCode. But if I debug it in VSCode, I see no console.log line being printed at all.

My Steps: 1. Open my project in VSCode My VS Code has installed react-native tools already

  1. Cmd+P then type command Debug: Start Debuging (it is an available command, I just select it)

  2. My App starts, DEBUG CONSOLE tab shows some lines but no line from my console.log command is shown

How do I write to console from a .js method?

console.log is not showing anything in Console tab in 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. If I run this through XCode, I will see console.log line above printed in XCode. But if I debug it in VSCode, I see no console.log line being printed at all.

My Steps: 1. Open my project in VSCode My VS Code has installed react-native tools already

  1. Cmd+P then type command Debug: Start Debuging (it is an available command, I just select it)

  2. My App starts, DEBUG CONSOLE tab shows some lines but no line from my console.log command is shown

Share Improve this question edited Aug 20, 2017 at 21:17 pixel asked Aug 20, 2017 at 17:20 pixelpixel 10.6k20 gold badges98 silver badges189 bronze badges 2
  • show some actual code. – Khurram Commented Aug 20, 2017 at 17:31
  • Maybe react-native is grabbing the console object? Try assigning the console object to your own var before importing react-native. Just a thought. – bvj Commented Sep 4, 2017 at 7:37
Add a comment  | 

3 Answers 3

Reset to default 10

I added:

"outputCapture": "std"

to my debug launch configuration and console.log statements work in the "DEBUG CONSOLE" tab.

Alternatively:

"console": "integratedTerminal" 

shows console.log in the "TERMINAL" tab.

Debug > Start Debugging F5 and see the output at DEBUG CONSOLE

I have the same issue.

I'm opening in a browser ("type": "vscode-edge-devtools.debug") in the configuration.

In the browser, if I hit f12 and go to the 'console' tab, that appears to be where the console.log is writing to.

发布评论

评论列表(0)

  1. 暂无评论