更改Google Chrome中的局部变量或函数参数 [英] Change local variable or function parameter in google chrome

查看:335
本文介绍了更改Google Chrome中的局部变量或函数参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用chrome的devtools调试/修改非本地javascript文件(因此我无法对其进行编辑).

I'm using chrome's devtools to debug/modify a non-local javascript file(so I can't edit it).

代码相当复杂,并且在函数内部定义了函数,并始终使用这些指针.

The code is rather complex and defines function inside of functions and uses these pointers throughout.

重点是,我不知道自己在过程中的确切位置,但可以将断点设置为需要修改的变量.但是我不知道如何修改它.我可以在本地面板下添加手表或对其进行修改,但实际上并不会改变(一旦该值恢复为原始值,则逐步执行该操作)

The point is that I do not know where I'm exactly at in the process but I can set a breakpoint to a variable I need to modify. BUT I can't figure out how to modify it. I can add a watch or modify it under the locals panel BUT it won't actually change (after stepping once the value reverts to original)

那么如何更改变量?我不知道为什么这么难.在我的传统调试中,您可以简单地在watch或locals中编辑值,它将对其进行修改.我曾尝试在控制台上对其进行修改,但我想我不知道变量的完整路径,而且我总是会得到未定义的变量.

So how can I change the variable? I don't know why it is so difficult. In my traditional debugging you can simply edit the value in the watch or locals and it will modify it. I've tried modifying it at the console but I guess I don't know the complete path to the variable and I always get an undefined variable.

我要做的就是在设置断点的某些函数中修改局部变量或参数.

All I want to do is modify a local variable or argument in side some function I set a breakpoint at.

推荐答案

尝试在控制台中执行此操作.例如:window.myVar = "newValue"

Try doing this in the console. E.g.: window.myVar = "newValue"

这篇关于更改Google Chrome中的局部变量或函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆