我想问一问为什么当你在ember上打印出来时它会给你一个字符串?但如果你输入它,它会给你一个功能吗?
ex. sample = Ember.Route.extend();
console.log(sample); // prints (subclass of Ember.Route)
console.log(typeof sample); // function
有人可以解释一下吗?除了他们难以掌握的文档。即使使用ember检查员,也很难在ember上进行调试。是否有任何工具或方法来正确调试ember。
在Ember调试方面,您可能已经读过: http://emberjs.com/guides/understanding-ember/debugging/
有一些很棒的功能,你可以在开发过程中打开什么,以获取更多信息,以及在幕后发生的事情。
您可以在app.js中插入:
var App = Ember.Application.extend({
LOG_TRANSITIONS_INTERNAL: true,
LOG_ACTIVE_GENERATION: true,
LOG_VIEW_LOOKUPS: true,
LOG_RESOLVER: true,
});
Ember.run.backburner.DEBUG = true;
Ember.ENV.RAISE_ON_DEPRECATION = true;
Ember.LOG_STACKTRACE_ON_DEPRECATION = true;
Ember.LOG_BINDINGS = true;
Ember.RSVP.on('error', function(error) {
Ember.Logger.assert(false, error);
});
你可以停止你的代码 如果你写 debugger
在你的代码中。我经常使用它来弄清楚那里发生了什么。
就你的问题而言,如果你扩展一个Ember类,它基本上创建一个新函数,但表现为扩展类的子类。你可以检查一下那里发生了什么: https://github.com/emberjs/ember.js/blob/v1.7.0/packages/ember-runtime/lib/system/core_object.js#L536-L556
当你运行你的Ember应用程序时,你的应用程序将被包裹在一个 容器,所以如果你需要访问属性或变量,你必须使用它 - 假设你的应用程序名称是'App':
App.__container__.lookup("controller:application").get("currentRouteName")
App.__container__.lookup("controller:application").get("currentPath")
App.__container__.lookup("controller:application").get("model")
需要一段时间才能了解如何调试您的余烬应用程序,但值得学习并投入更多时间,因为以后会非常方便。
如果您有任何疑问,请不要犹豫,我们可以解决。
关于调试器;
它就像一个断点,你可以停止代码。必须在Chrome中打开“Inspect element”/“Developer Tool”。这里的小例子: http://jsbin.com/cugetoxoyira/45
源代码: http://jsbin.com/cugetoxoyira/45/edit
在第18行,有一个 debugger;
,因此您可以在控制台中检查控制器或模型参数中的内容。你只需输入 controller
在Chrome的Developer Tool中的控制台中。
在Ember调试方面,您可能已经读过: http://emberjs.com/guides/understanding-ember/debugging/
有一些很棒的功能,你可以在开发过程中打开什么,以获取更多信息,以及在幕后发生的事情。
您可以在app.js中插入:
var App = Ember.Application.extend({
LOG_TRANSITIONS_INTERNAL: true,
LOG_ACTIVE_GENERATION: true,
LOG_VIEW_LOOKUPS: true,
LOG_RESOLVER: true,
});
Ember.run.backburner.DEBUG = true;
Ember.ENV.RAISE_ON_DEPRECATION = true;
Ember.LOG_STACKTRACE_ON_DEPRECATION = true;
Ember.LOG_BINDINGS = true;
Ember.RSVP.on('error', function(error) {
Ember.Logger.assert(false, error);
});
你可以停止你的代码 如果你写 debugger
在你的代码中。我经常使用它来弄清楚那里发生了什么。
就你的问题而言,如果你扩展一个Ember类,它基本上创建一个新函数,但表现为扩展类的子类。你可以检查一下那里发生了什么: https://github.com/emberjs/ember.js/blob/v1.7.0/packages/ember-runtime/lib/system/core_object.js#L536-L556
当你运行你的Ember应用程序时,你的应用程序将被包裹在一个 容器,所以如果你需要访问属性或变量,你必须使用它 - 假设你的应用程序名称是'App':
App.__container__.lookup("controller:application").get("currentRouteName")
App.__container__.lookup("controller:application").get("currentPath")
App.__container__.lookup("controller:application").get("model")
需要一段时间才能了解如何调试您的余烬应用程序,但值得学习并投入更多时间,因为以后会非常方便。
如果您有任何疑问,请不要犹豫,我们可以解决。
关于调试器;
它就像一个断点,你可以停止代码。必须在Chrome中打开“Inspect element”/“Developer Tool”。这里的小例子: http://jsbin.com/cugetoxoyira/45
源代码: http://jsbin.com/cugetoxoyira/45/edit
在第18行,有一个 debugger;
,因此您可以在控制台中检查控制器或模型参数中的内容。你只需输入 controller
在Chrome的Developer Tool中的控制台中。
只是用 {{log "This is logged" foo "And so is this"}}
参考: http://handlebarsjs.com/builtin_helpers.html