Javascript 主干路由器不工作(无参数)
我有 以下URL不起任何作用Javascript 主干路由器不工作(无参数),javascript,backbone.js,Javascript,Backbone.js,我有 以下URL不起任何作用 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'
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');
});
您的路由器将为URL工作,如
http://localhost:8080/App1/index.html /*should give alert('Index Page')*/
http://localhost:9090/App1/index.html#view /*should give alert('View1')*/
确保调用
Backbone.history.start()
路由初始URL。是否调用Backbone.history.start()
?
http://localhost:8080/
http://localhost:8080/#view