问题描述
我得到 Cannot call 'start' of undefined
调用...
Backbone.history.start()
当运行一些检查时,Backbone 返回对象但 Backbone.history 返回未定义.
When running some checks Backbone returns the object but Backbone.history returns undefined.
这可能是什么原因?
谢谢
推荐答案
控制器上有路由吗?Backbone 仅在至少指定了一条路由后才创建历史记录.
Do you have any routes on the controller? Backbone only creates the history once at least one route is specified.
更多:
类型错误:无法调用未定义的方法start"**
嗯,由于某种原因 Backbone.history 是未定义的,所以没有启动方法就可以了.原来 Backbone.js 创建了一个实例Backbone.History(大写'H')的名称称为Backbone.history(小写'H')case ‘h’) 一旦一个控制器被创建,它至少有一个其上指定的路线.这是有道理的,因为历史管理只是如果有路由要响应,则需要.
Hmm, for some reason Backbone.history is undefined, and so there is no start method on it. It turns out that Backbone.js creates an instance of Backbone.History (upper case ‘H’) called Backbone.history (lower case ‘h’) once a controller has been created that has at least one route specified on it. This makes sense, as history management is only required if there are routes to respond to.
http://tinnedfruit.com/2011/04/26/testing-backbone-apps-with-jasmine-sinon-3.html
这篇关于启动backbone.js 历史时无法调用未定义的“开始".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!