在 Chrome 中实时编辑 Javascript,例如在 Visual Studio 中编辑并继续

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10208922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 09:02:17  来源:igfitidea点击:

Editing Javascript in Chrome real time, like Edit and Continue in Visual Studio

javascriptdebugginggoogle-chromegoogle-chrome-devtools

提问by GravityWell

Chrome can edit Javascript on the fly, without a full page refresh, similar to Visual Studio's edit and continue ability for code behind files. This helps when prototyping javascript functions or snippets.

Chrome 可以即时编辑 Javascript,无需刷新整个页面,类似于 Visual Studio 对文件隐藏代码的编辑和继续功能。这有助于对 javascript 函数或片段进行原型设计。

You have to hit a breakpoint, then hit the edit button. Then the current function will be unrolled, then you can step back into it with your changes in effect. Not nearly as nice as VS edit and continue, but at least it's something. Also it appears some things cannot be changed.

您必须点击断点,然后点击编辑按钮。然后将展开当前函数,然后您可以在更改生效时返回到它。不像 VS 编辑和继续那么好,但至少它是一些东西。此外,似乎有些事情无法更改。

Is there any other tool that can do live javascript edits, or is there a better way? Visual Studio 2010 does not as far as I can tell.

有没有其他工具可以进行实时 javascript 编辑,或者有更好的方法吗?据我所知,Visual Studio 2010 没有。

function test1() {

    debugger;

    var data_array = [];
    var newvar1 = newfunc()+'dc'; // ok - can edit
    var newvar2 = "hey2"; // ok - can edit
    var newvar3 = 4; // ok can edit

    var someobj = {1:"hey2", 2:"string2"}; // no - can not edit values after executed once
    var word_array = ["hello", "goodbye", "adios"]; // no - can not edit values after executed once

    for (var counter = 0; counter < 500; counter++) {
        data_array[counter] = counter + word_array[Math.floor(Math.random() * (word_array.length))];
    }

}


function newfunc() {
     return "yes44";   
}

Similar questions:
Using Google Chrome to debug and edit javascript embedded in HTML page
Editing in the Chrome debugger

类似问题:
使用谷歌浏览器调试和编辑嵌入在 HTML 页面中的javascript
在 Chrome 调试器中编辑

Autosave plugin http://www.google.com/intl/cs-CZ/events/io/2010/sessions/chrome-developer-tools.htmlGoogles presentation: https://github.com/NV/chrome-devtools-autosave

自动保存插件 http://www.google.com/intl/cs-CZ/events/io/2010/sessions/chrome-developer-tools.htmlGoogles 演示:https: //github.com/NV/chrome-devtools-自动保存

采纳答案by beefeather

You may want to try Chrome Dev Tools for Javaproject. It is an Eclipse plugin for debugging JavaScript in Chrome that could be used together with a JavaScript IDE plugin. This way you edit and debug and live edit the very same file (see text).

您可能想尝试用于 Java项目的Chrome Dev Tools。它是一个用于在 Chrome 中调试 JavaScript 的 Eclipse 插件,可以与 JavaScript IDE 插件一起使用。通过这种方式,您可以编辑、调试和实时编辑完全相同的文件(请参阅文本)。