2015-09-19 442 views
0

骨干路由器不能正常工作(不带参数)

var Router1 = Backbone.Router.extend({ 
    routes: { 
     '': 'index', 
     'view': 'view1' 
    } 
}); 

var router1 = new Router1(); 
router1.on('route:index', function(){ 
     alert('Index Page'); 
}); 
router1.on('route:view1', function(){ 
     alert('View 1'); 
}); 

以下网址没有做任何事情

http://localhost:8080/App1/index.html  /*should give alert('Index Page')*/ 
http://localhost:9090/App1/index.html#view /*should give alert('View1')*/ 
+2

你叫'Backbone.history.start()'? – Spike

回答

0

您的路由器会为网址的工作就像

http://localhost:8080/ 
http://localhost:8080/#view 

确保您拨打Backbone.history.start()来路由初始网址。