更改 Google Chrome 开发者工具上的 JavaScript 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15060085/
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 23:19:42  来源:igfitidea点击:

Change JavaScript files on Google Chrome's Developer Tools

javascriptgoogle-chrome

提问by GangstaGraham

I know how to use JavaScript on Google Chrome's console.

我知道如何在 Google Chrome 的控制台上使用 JavaScript。

But is it possible to edit JavaScript files from within Google Chrome's developer tools and see the changes immediately? If so, how?

但是是否可以从 Google Chrome 的开发人员工具中编辑 JavaScript 文件并立即查看更改?如果是这样,如何?

I have tried changing the code, but it has no effect on the page.

我尝试更改代码,但它对页面没有影响。

回答by loislo

You can edit javascript of the page. You had to make a double click in the old version of chrome or in the recent version you need to make a single click in js file. After that you need to press Ctrl+S or Cmd+S on Mac. Then DevTools will send the changed code to V8.

您可以编辑页面的javascript。您必须在旧版本的 chrome 中双击,或者在最新版本中您需要在 js 文件中单击一下。之后,您需要在 Mac 上按 Ctrl+S 或 Cmd+S。然后 DevTools 会将更改后的代码发送到 V8。

If you are in a debug session and stay on a pause in a function you can edit it and after Ctrl+S v8 will move the execution point out from the edited function so you will be able to pass it again.

如果您在调试会话中并停留在函数中,您可以对其进行编辑,然后按 Ctrl+S v8 会将执行点从已编辑的函数中移出,这样您就可以再次传递它。

回答by jfriend00

You could redefine a global function or change the value of a variable in scope, but I'm not aware of any way in the Chrome Dev Tools to edit your code while live. I edit, then hit refresh.

您可以重新定义全局函数或更改范围内变量的值,但我不知道 Chrome 开发工具中有任何方法可以在实时编辑代码。我编辑,然后点击刷新。

You can live edit CSS in the Sources tab.

您可以在 Sources 选项卡中实时编辑 CSS。