是否可以注册一个路线/pages/*url
而不是/pages/*url/edit/
其中URL可以是这样的foo/bar/and-so-on
?
Answer 1:
router.route支持使用一个正则表达式本身。
initialize: function(options) {
// Matches /117-a/b/c/open, passing "117-a/b/c" to this.open
this.route(/^(.*?)\/open$/, "open");
},
open: function(id) { ... }
文章来源: Backbone.js and regex routing