define([
'jquery',
'underscore',
'backbone',
'app',
'models/sessionmodel',
'views/home/homeview',
], function(
$,
_,
Backbone,
app,
SessionModel,
HomeView
){
AppRouter = Backbone.Router.extend({
initialize: function(options){},
routes : {
'' :'showhome',
},
showhome : function(){
this.show(new HomeView());
},
});
return AppRouter;
});
这是我的主要内容,这是每个Backbone标准的首次亮点。我有另一个名为app的文件,它创建了一个空对象并返回它......
require.config({
paths: {
jquery: 'libs/jquery/jquery-1.8.2',
underscore: 'libs/underscore/underscore-min',
backbone: 'libs/backbone/backbone-1.0.0-min',
text: 'libs/require/text',
router: 'router',
app: 'app'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
}
}
});
require(['app','router', 'models/sessionmodel'], function(app, AppRouter, SessionModel) {
app.router = new AppRouter();
app.session = new SessionModel();
app.session.checkAuth({
complete: function(){
Backbone.history.start();
}
});
});
当我控制台记录这个时,路由器缺少其默认方法(特别是导航,但另外还有其他如开,关,触发等)。
答案 0 :(得分:2)
您似乎没有检查记录对象的__proto__
属性:
答案 1 :(得分:0)
您必须实例化它:var router = new AppRouter();