URL参数,使用backbone.js

时间:2013-05-07 07:38:41

标签: url backbone.js underscore.js

我有这样的网址:

something.com/#page/id(使用backbone.js构建)

我想检查是否存在该ID使用underscore.js在DOM中使用它,我知道我可以用window.location.href.split来做到这一点,但我只是想知道是否有更合适和更清洁的方式..

1 个答案:

答案 0 :(得分:1)

"page/:id": "someFunction" #this will be your route and it should have a function.

# In that someFunction you can check parameter (id) as shown below.

someFunction: function (id) {
    console.log(id);
}