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