javascript 使用 Plunker,如何从浏览器控制台访问变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17666179/
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
Using Plunker, How to access variable from the browser console
提问by Mike Barlow - BarDev
I'm using Plunker (http://plnkr.co/) to test JavaScript. From the browser console I want to access variables that I defined in the script.
我正在使用 Plunker ( http://plnkr.co/) 来测试 JavaScript。我想从浏览器控制台访问我在脚本中定义的变量。
In Plunker, can anyone tell me how to access the variable "someValue" from the browser console.
在 Plunker 中,谁能告诉我如何从浏览器控制台访问变量“someValue”。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<script type="text/javascript">
var someValue = 3
console.log(someValue);
</script>
</body>
</html>
回答by Mike Barlow - BarDev
I figured out one possible solution. In Google Chrome's Developer Tools on the bottom of the developer console "top frame" can be changed to "run.plnkr.co" (see image below). This will change the scope of the console and the variables in the script can now be accessed.
我想出了一种可能的解决方案。在 Google Chrome 的开发者工具中,开发者控制台底部的“顶框”可以更改为“run.plnkr.co”(见下图)。这将更改控制台的范围,现在可以访问脚本中的变量。
Here's the answer for jsFiddle: Access variables in jsFiddle from Javascript console?
这是 jsFiddle 的答案: Access variables in jsFiddle from Javascript console?
回答by Nadir
or you can use http://jsbin.com/which displays the console directly
或者您可以使用直接显示控制台的http://jsbin.com/
回答by DL Narasimhan
回答by jcdsr
Try to use console.debug( variable )
;
尝试使用console.debug( variable )
;
Take a look in this post as well:
也看看这篇文章: