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

时间:2012-04-18 12:00:28

标签: javascript debugging google-chrome google-chrome-devtools

Chrome可以动态编辑Javascript,无需刷新整页,类似于Visual Studio的编辑和继续编写代码隐藏文件的能力。这有助于原型化javascript函数或片段。

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

还有其他工具可以进行实时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";   
}

类似的问题:
Using Google Chrome to debug and edit javascript embedded in HTML page
Editing in the Chrome debugger

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

1 个答案:

答案 0 :(得分:1)

您可能想尝试Chrome Dev Tools for Java项目。它是一个Eclipse插件,用于在Chrome中调试JavaScript,可以与JavaScript IDE插件一起使用。这样您就可以编辑和调试并实时编辑同一个文件(参见text)。