如何在firebug中查看javascript中的对象
许多文章都谈到可以在浏览器中查看页面中javascript的对象。但是我测试就不行。
在ubuntu14.04,浏览器是firfox32.0,安装了firebug2.04.
有一个页面如下:
-------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" id="index">
<ul>
{{#each item in model}}
<li>{{item}}</li>
{{/each}}
</ul>
</script>
<script src="js/libs/jquery-1.10.2.js"></script>
<script src="js/libs/handlebars-1.1.2.js"></script>
<script src="js/libs/ember-1.7.0.js"></script>
<script src="js/app.js"></script>
<!-- to activate the test runner, add the "?test" query string parameter -->
<script src="tests/runner.js"></script>
</body>
</html>
-------------------------------------------------
这个js/app.js的内容如下:
-----------------------------------------------
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue', 'green'];
}
});
------------------------------------------------------------
根据文档的提示,我现在想从浏览器的控制台中直接操作javascript对象model,增加颜色。
我这样操作,打开F12,然后切换到控制台,输入model,出现错误:
------------------------------------------------------------------
model
ReferenceError: model is not defined
model
-----------------------------------------------------------------
请多多指导。