我用backbone.js @创建一个测试用例:http: //jsfiddle.net/VWBvs/5/
路线定义为
var AppRouter = Backbone.Router.extend({
routes: {
"/posts/:id" : "getPost",
"/download/*path": "downloadFile",
"*actions" : "defaultRoute"
},
getPost: function(id) {
alert(id);
},
defaultRoute : function(actions){
alert(actions);
},
downloadFile: function( path ){
alert(path); // user/images/hey.gif
},
loadView: function( route, action ){
alert(route + "_" + action); // dashboard_graph
}
});
var app_router = new AppRouter;
Backbone.history.start();
当我改变功能
defaultRoute : function(actions){
alert(actions);
},
至
defaultRoute : function(actions){
var action = actions
},
所有其他路线都不起作用,这意味着不会弹出对话框。
但是当重新更改代码时,一切正常。
这真的很奇怪,让我很困惑。真诚的求救......