开发者

How to have a fallback route to catch unknown pages in backbone.js

开发者 https://www.devze.com 2023-03-30 15:52 出处:网络
I have a set of routes set up like the following: routes: { \'!/home\': \'home\', 开发者_Python百科\'!/home/:page\': \'home\'

I have a set of routes set up like the following:

routes: {
  '!/home': 'home',
  开发者_Python百科'!/home/:page': 'home'
}

What I'm wondering is, how do I configure a route such that if the user requests an unknown page I can easily redirect to a static 404.html page?


In your Router (the first two routes are for example):

routes: {
  "path/": "objectList",
  "path/:id": "objectItem",
  ":whatever": "notFound"
}

The last is the most general route possible, and will pick up everything not recognized by more specific routes.

0

精彩评论

暂无评论...
验证码 换一张
取 消