因为维护公司的老项目而接触到backbone。以前是只闻其名,未见其码。
因为其他项目需要跳转到本项目的某个页面,但是需要UI改变。
考虑的方法是给路由添加一个可选参数。代码如下:
正常路由:
1 routes : { 2 "" : "indexAction", 3 "index" : "indexAction", 4 "resource" : "resourceAction", 5 "mine" : "mineAction", 6 },
传参路由:
1 routes : { 2 "growup/:showFlag" : "growupAction", 3 "serviceDetail/:meId" : "serviceDetailAction", 4 "mine/:type" : "mineAction", 5 "question/:index/:content" : "questionAction", 6 },
传递可选参数路由:
routes : { "live/:id/:meId/:type(/:from)" : "liveAction", "module3(/:name)(/:age)" : "moduleContent" },
遇到一点儿看一点儿吧,还是多看看主流框架划算。