Show how to use each routing strategy in docs (#2332)

This commit is contained in:
Gilbert 2018-12-06 17:30:43 -06:00 committed by Isiah Meadows
parent e068bd421c
commit eaa1c13664

View file

@ -214,9 +214,9 @@ Routing without page refreshes is made partially possible by the [`history.pushS
The routing strategy dictates how a library might actually implement routing. There are three general strategies that can be used to implement a SPA routing system, and each has different caveats:
- Using the [fragment identifier](https://en.wikipedia.org/wiki/Fragment_identifier) (aka the hash) portion of the URL. A URL using this strategy typically looks like `http://localhost/#!/page1`
- Using the querystring. A URL using this strategy typically looks like `http://localhost/?/page1`
- Using the pathname. A URL using this strategy typically looks like `http://localhost/page1`
- `m.route.prefix('#!')` (default) Using the [fragment identifier](https://en.wikipedia.org/wiki/Fragment_identifier) (aka the hash) portion of the URL. A URL using this strategy typically looks like `http://localhost/#!/page1`
- `m.route.prefix('?')` Using the querystring. A URL using this strategy typically looks like `http://localhost/?/page1`
- `m.route.prefix('')` Using the pathname. A URL using this strategy typically looks like `http://localhost/page1`
Using the hash strategy is guaranteed to work in browsers that don't support `history.pushState`, because it can fall back to using `onhashchange`. Use this strategy if you want to keep the hashes purely local.