将 RequireJS 添加到 BackboneJS 应用程序后,我无法访问 chrome 控制台中的实例变量。
这是示例:
只有 BackboneJS:http ://todomvc.com/architecture-examples/backbone/
打开 chrome 控制台并输入 keys(window) 以查找在各种 BackboneJS 脚本中使用的实例变量为“app”:
// instance variable app is also found under window
keys(window)
["top", "window", "location", "external", "chrome", "Intl", "v8Intl", "document", "_gaq", "_gat", "gaGlobal", "$", "jQuery", "_", "Backbone", "Store", "app", "jQuery191046978461160324514", "ENTER_KEY", "css", "cssFile", "cssRule"]
// debug the app object with Collections, Models, Views, Routers, etc
app
Object {Todo: function, todos: child, TodoView: function, AppView: function, TodoRouter: child…}
AppView: function (){ return parent.apply(this, arguments); }
Todo: function (){ return parent.apply(this, arguments); }
TodoFilter: ""
TodoRouter: child
TodoView: function (){ return parent.apply(this, arguments); }
todos: child
__proto__: Object
BackboneJS + RequireJS:http ://todomvc.com/dependency-examples/backbone_require/
打开 chrome 控制台并输入 keys(window) 并尝试找出 BackboneJS 的实例变量,类似于上一个示例:
keys(window)
["top", "window", "location", "external", "chrome", "Intl", "v8Intl", "document", "_gaq", "requirejs", "require", "define", "_gat", "gaGlobal", "_", "$", "jQuery", "css", "cssFile", "cssRule", "Backbone", "Store", "jQuery191032673427602276206"]
// I cant debug the BackboneJS object when it is used with RequireJS
如何使用 RequireJS 在 BackboneJS 应用程序中访问相同的实例变量“app”?
当使用 RequireJS 时,有没有办法访问 Backbone 应用程序的集合、模型、视图、路由器等?
一个多星期以来我无法弄清楚这一点,有人可以帮助我吗?