简体   繁体   English

Electron - 断点仅在 main.js 中有效,但在 index.js 中无效

[英]Electron - Breakpoints only work in main.js, but not in index.js

since half an hour I work on the electron-Quick-Start-Tutorial.半个小时以来,我一直在研究 electron-Quick-Start-Tutorial。 Like the docs told me, I created the filestructure like this:就像文档告诉我的那样,我创建了这样的文件结构:

  • package.json package.json
  • main.js主程序
  • index.html index.html

Departing from the docs I did changes on the launch.json to make my project start on F5 in Visual Studio Code:与文档不同,我对 launch.json 进行了更改,以使我的项目在 Visual Studio Code 中按 F5 启动:

       "type": "node",
        "request": "launch",
        "name": "Programm starten",
        "program": "${workspaceRoot}/main.js",
        "cwd": "${workspaceRoot}",
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
        "runtimeArgs": [
            "--enable-logging"
        ]

My oncklick()-functions reside in index.js, that is referenced in index.html:我的 oncklick() 函数驻留在 index.js 中,它在 index.html 中被引用:

<script src="index.js"></script>

It's all fine, but how can I make my index.js-breakpoints work within VSC?一切都很好,但我怎样才能让我的 index.js 断点在 VSC 中工作? Main.js-breakpoints stop as they should. Main.js 断点按预期停止。

Thx piccus谢谢piccus

can you change your launch.json like this and check this document http://electron.rocks/debugging-electron-in-vs-code-revised/你能像这样改变你的launch.json并检查这个文件http://electron.rocks/debugging-electron-in-vs-code-revised/

   {
    "name": "Debug",
    "type": "chrome",
    "request": "launch",
    "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
    "runtimeArgs": [
        "${workspaceRoot}",
        "--enable-logging",
        "--remote-debugging-port=9222"
     ],
     "sourceMaps": false
}

btw if its not a typo can you change your oncKlick function to onclick()顺便说一句,如果不是打字错误,您可以将 oncKlick function 更改为 onclick()

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

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