1

I wanted to allow any routes which start with # and any number

Example :

http://127.0.0.1/mypage/#435fsdfd

This should basically execute renderMyPage.

Tried below things but didn't work

routes : { 

    "" : "renderMyPage",
    "#:/" : "renderMyPage"

}
4

1 回答 1

0

一些东西:

如果您的应用程序不是从您的域的根 url / 提供的,您需要告诉 History 根的真正位置

Backbone.history.start({root: "/mypage/"});

您不需要在路由中定义哈希,如果您只想匹配哈希上的“某物”,这就足够了:

routes : { 
  "" : "renderMyPage",
  ":value" : "renderMyPage"
},

renderMyPage: function (value) {

}

在最新的骨干网(0.9.10)中,您可以使用可选参数,这样您就可以在一条路线中完成所有事情

routes : { 
  "(:value)" : "renderMyPage"
},
于 2013-01-18T14:48:28.700 回答