- 屬性 routes: 用來設定 routes hash 對應的動作 ( actions, functions )。
- 方法 initialize: 初始化呼叫, 自行定義。建立 Router 物件時若傳入 Object 物件, 讓物件會視為 routes 的設定。
- 方法 route: 動態設定 routes hash 對應的動作。
- 方法 navigate: 呼叫此方法以變更 URL。第一個參數為字串, 第二個參數為 Object 物件。Object 物件屬性 trigger 設定為 true 時, 表示要呼叫 route function。Object 物件屬性 replace設定為 true 時, 表示不留在 history 裡。
呼叫 Backbone.history.start() 時傳入的 Object 物件屬性可以有三個:
- 屬性 pushState: 設定為 true 時表示使用 HTML5 的 pushState 功能, 將不會在 URL 使用 # , 這通常需要做後端 URL mapping 設定。
- 屬性 root: 如果路徑不是 / 可以使用 root 設定。
- 屬性 silent: 如果不願在初始化時呼叫 route function, 把 silent 設定為 trrue。
在 IE 建議不要使用以上三個屬性設定... 囧。