mat*_*eok 7 javascript url router hashtag backbone.js
我需要让它工作:
routes: {
':product' : 'showProduct',
':product/:detail': 'showProductDetail'
Run Code Online (Sandbox Code Playgroud)
即使之后设置了':product'路由,也不会调用showProductDetail.我尝试了以下内容
routes: {
':product(/:detail)': showProductOrDetail
}
Run Code Online (Sandbox Code Playgroud)
但是只有第二个参数发生变化时才会调用它.重要的是我有产品本身或网址中的产品和细节.
有谁知道如何解决这一问题?
Szy*_*zol 17
对你的问题有一点hacky解决方案.我觉得有一个更好的方法来做到这一点,但这应该工作:
routes: {
"product/:id": "showProduct",
"product/:id/details/:did": "showDetails"
},
showProduct: function(id) {
this.showDetails(id);
},
showDetails: function(id, did) {
// Check did for undefined
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14060 次 |
| 最近记录: |