71 |
72 | `
73 | }
74 | ```
75 |
76 | ## ``
77 |
78 | The common low-level interface for all router components. Typically apps will use one of the high-level routers instead:
79 |
80 | - ``
81 | - ``
82 | - ``
83 | - ``
84 |
85 | All the router components must have a single slot child, that will receive these props:
86 |
87 | - `history`
88 | - `location`
89 | - `match`
90 |
91 | ```js
92 | const history = createBrowserHistory({
93 | basename: '/',
94 | //...
95 | });
96 |
97 | new Vue({
98 | template: `
99 |
103 |
104 |
105 | `
106 | });
107 | ```
108 |
109 | Props:
110 |
111 | ### history
112 |
113 | - Type: `History`
114 | - Required
115 |
116 | A [history](https://github.com/ReactTraining/history) object to use for navigation.
117 |
118 |
119 | ## ``
120 |
121 | A `` that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.
122 |
123 | ```html
124 |
131 |
132 |
133 | ```
134 |
135 | Props: read `createBrowserHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
136 |
137 | ### basename
138 |
139 | - Type: `String`
140 | - Defaults: `''`
141 |
142 | The base URL for all locations. If your app is served from a sub-directory on your server, you’ll want to set this to the sub-directory. A properly formatted basename should have a leading slash, but no trailing slash (like `/basename`).
143 |
144 | ### getUserConfirmation
145 |
146 | - Type: `Function`
147 |
148 | A function to use to confirm navigation. Defaults to using `window.confirm` like below.
149 |
150 | ```js
151 | // this is the default behavior
152 | function getConfirmation(message, callback) {
153 | const allowTransition = window.confirm(message);
154 | callback(allowTransition);
155 | }
156 | ```
157 |
158 | ### forceRefresh
159 |
160 | - Type: `Boolean`
161 | - Defaults: `false`
162 |
163 | If true the router will use full page refreshes on page navigation. You probably only want this in browsers that don’t support the `HTML5 history API`.
164 |
165 | ### keyLength
166 |
167 | - Type: `Number`
168 | - Defaults: `6`
169 |
170 | The length of location.key. Read more details on [location.key](https://github.com/ReactTraining/history#listening).
171 |
172 |
173 | ## ``
174 |
175 | A `` that uses the hash portion of the URL (i.e. window.location.hash) to keep your UI in sync with the URL.
176 |
177 | **IMPORTANT NOTE**: Hash history does not support `location.key` or `location.state`.
178 |
179 | > Read `createHashHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
180 |
181 | ```html
182 |
188 |
189 |
190 | ```
191 |
192 | Props:
193 |
194 | ### basename
195 |
196 | - Type: `String`
197 | - Defaults: `''`
198 |
199 | The base URL for all locations. A properly formatted basename should have a leading slash, but no trailing slash (like '/basename').
200 |
201 | ### hashType
202 |
203 | - Type: `String`
204 | - Defaults: `'slash'`
205 |
206 | The type of encoding to use for window.location.hash. Available values are:
207 |
208 | - "slash" - Creates hashes like `#/` and `#/sunshine/lollipops`
209 | - "noslash" - Creates hashes like `#` and `#sunshine/lollipops`
210 | - "hashbang" - Creates “ajax crawlable” (deprecated by Google) hashes like `#!/` and `#!/sunshine/lollipops`
211 |
212 | ### getUserConfirmation
213 |
214 | - Type: `Function`
215 |
216 | A function to use to confirm navigation. Defaults to using `window.confirm` like below.
217 |
218 | ```js
219 | // this is the default behavior
220 | function getConfirmation(message, callback) {
221 | const allowTransition = window.confirm(message);
222 | callback(allowTransition);
223 | }
224 | ```
225 |
226 |
227 | ## ``
228 |
229 | A `` that keeps the history of your “URL” in memory (does not read or write to the address bar). Useful in tests and non-browser environments.
230 |
231 | > Read `createMemoryHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
232 |
233 | ```html
234 |
241 |
242 |
243 | ```
244 |
245 | Props:
246 |
247 | ### initialEntries
248 |
249 | - Type: `[String | Location]`
250 | - Defaults: `['/']`
251 |
252 | An array of locations in the history stack. These may be full-blown `location` objects with { pathname, search, hash, state } or simple string URLs.
253 |
254 | ### initialIndex
255 |
256 | - Type: `Number`
257 | - Defaults: `0`
258 |
259 | The initial location’s index in the array of initialEntries.
260 |
261 | ### keyLength
262 |
263 | - Type: `Number`
264 | - Defaults: `6`
265 |
266 | The length of location.key.
267 |
268 | ### getUserConfirmation
269 |
270 | - Type: `Function`
271 | - Defaults: `null`
272 |
273 | A function to use to confirm navigation. You must use this option when using `` directly with a ``.
274 |
275 |
276 | ## ``
277 |
278 | A `` that never changes location.
279 |
280 | ```html
281 |
287 |
288 |
289 | ```
290 |
291 | Props:
292 |
293 | ### basename
294 |
295 | - Type: `String`
296 | - Defaults: `''`
297 |
298 | The base URL for all locations. A properly formatted basename should have a leading slash, but no trailing slash (like `/basename`).
299 |
300 | ### context
301 |
302 | - Type: `Object`
303 | - Defaults: `{}`
304 |
305 | A plain JavaScript object. During the render, components can add properties to the object to store information about the render.
306 |
307 | ### location
308 |
309 | - Type: `[String | Location]`
310 | - Defaults: `'/'`
311 |
312 | The URL the server received, probably `req.url` on a node server. Or a `location` object shaped like `{ pathname, search, hash, state }`.
313 |
314 |
315 | ## ``
316 |
317 | The `` component is perhaps the most important component in `vue-router-lite` to understand and learn to use well. Its most basic responsibility is to render some UI when a location matches the route’s path.
318 |
319 | The `` component must have a single slot child, that will receive these props:
320 |
321 | - `history`
322 | - `location`
323 | - `match`
324 |
325 | Consider the following code:
326 |
327 | ```js
328 | import { BrowserRouter as Router, Route } from 'vue-route-lite';
329 |
330 | const App = {
331 | components: {
332 | Router,
333 | Route
334 | },
335 | template: `
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 | `
347 | }
348 | ```
349 |
350 | If the location of the app is `/` then the UI hierarchy will be something like:
351 |
352 | ```html
353 |
354 |
355 |
356 |
357 | ```
358 |
359 | And if the location of the app is `/news` then the UI hierarchy will be:
360 |
361 | ```html
362 |
363 |
364 |
365 |
366 | ```
367 |
368 | Props:
369 |
370 | ### path
371 |
372 | - Type: `String | String[]`
373 |
374 | Any valid URL path or array of paths that [path-to-regexp@^3.0.0](https://github.com/pillarjs/path-to-regexp) understands.
375 |
376 | Routes without a path always match.
377 |
378 | ### exact
379 |
380 | - Type: `Boolean`,
381 | - Defaults: `false`
382 |
383 | When true, will only match if the path matches the location.pathname exactly.
384 |
385 | path | location.pathname | exact | matches?
386 | ---- | --- | --- | ---
387 | /one | /one/two | true | no
388 | /one | /one/two | false | yes
389 |
390 | ### strict
391 |
392 | - Type: `Boolean`,
393 | - Defaults: `false`
394 |
395 | When true, a path that has a trailing slash will only match a location.pathname with a trailing slash. This has no effect when there are additional URL segments in the location.pathname.
396 |
397 | path | location.pathname | matches?
398 | ---- | --- | ---
399 | /one/ | /one | no
400 | /one/ | /one/ | yes
401 | /one/ | /one/two | yes
402 |
403 | Warning: strict can be used to enforce that a location.pathname has no trailing slash, but in order to do this both strict and exact must be true.
404 |
405 | path | location.pathname | matches?
406 | ---- | --- | ---
407 | /one | /one | yes
408 | /one | /one/ | no
409 | /one | /one/two | no
410 |
411 | ### sensitive
412 |
413 | - Type: `Boolean`,
414 | - Defaults: `true`
415 |
416 | Whether the paths is case sensitive?
417 |
418 | ### forceRender
419 |
420 | - Type: `Boolean`,
421 | - Defaults: `true`
422 |
423 | If true, the route component will always render whether matched, user can control the slot's show status.
424 |
425 | ```html
426 |
427 |
428 |
429 | ```
430 |
431 | ### location
432 |
433 | - Type: `Location`
434 |
435 | A `` element tries to match its path to the current history location (usually the current browser URL). However, a location with a different pathname can also be passed for matching.
436 |
437 | This is useful in cases when you need to match a `` to a location other than the current history location.
438 |
439 |
440 | ## ``
441 |
442 | Used to prompt the user before navigating away from a page. When your application enters a state that should prevent the user from navigating away (like a form is half-filled out), render a ``.
443 |
444 | Props:
445 |
446 | ### when
447 |
448 | - Type: `Boolean`,
449 | - required
450 |
451 | Instead of conditionally rendering a `` behind a guard, you can always render it but pass `:when="true"` or `:when="false"` to prevent or allow navigation accordingly.
452 |
453 | ### message
454 |
455 | - Type: `[Function | String]`,
456 | - required
457 |
458 | The message to prompt the user with when they try to navigate away.
459 |
460 | If message is a function, it will be called with the next location and action the user is attempting to navigate to. Return a string to show a prompt to the user or true to allow the transition.
461 |
462 |
463 | ## ``
464 |
465 | Rendering a `` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do.
466 |
467 | Props:
468 |
469 | ### from
470 |
471 | - Type: `String`
472 |
473 | A pathname to redirect from. Any valid URL path that [path-to-regexp@^3.0.0](https://github.com/pillarjs/path-to-regexp) understands. All matched URL parameters are provided to the pattern in to. Must contain all parameters that are used in to. Additional parameters not used by to are ignored.
474 |
475 | ### to
476 |
477 | - Type: `[String | Location]`,
478 | - required
479 |
480 | The URL to redirect to. Any valid URL path that [path-to-regexp@^3.0.0](https://github.com/pillarjs/path-to-regexp) understands. All URL parameters that are used in to must be covered by from.
481 |
482 | Or a location to redirect to. pathname can be any valid URL path that [path-to-regexp@^3.0.0](https://github.com/pillarjs/path-to-regexp) understands.
483 |
484 | ### push
485 |
486 | - Type: `Boolean`,
487 | - Defaults: `false`
488 |
489 | When true, redirecting will push a new entry onto the history instead of replacing the current one.
490 |
491 | ### exact
492 |
493 | - Type: `Boolean`,
494 | - Defaults: `false`
495 |
496 | Match from exactly; equivalent to ` exact`.
497 |
498 | ### strict
499 |
500 | - Type: `Boolean`,
501 | - Defaults: `false`
502 |
503 | Match from exactly; equivalent to ` strict`.
504 |
505 | ### sensitive
506 |
507 | - Type: `Boolean`,
508 | - Defaults: `true`
509 |
510 | Match from exactly; equivalent to ` sensitive`.
511 |
512 |
513 | ## ``
514 |
515 | Renders the first child `` or `` that matches the location.
516 |
517 | How is this different than just using a bunch of `s`?
518 |
519 | `` is unique in that it renders a route exclusively. In contrast, every `` that matches the location renders inclusively. Consider this code:
520 |
521 | ```html
522 |
523 |
524 |
525 | ```
526 |
527 | If the URL is `/about`, then ``, ``, and `` will all render because they all match the path. This is by design, allowing us to compose `s` into our apps in many ways, like sidebars and breadcrumbs, bootstrap tabs, etc.
528 |
529 | Occasionally, however, we want to pick only one `` to render. If we’re at `/about` we don’t want to also match `/:user` (or show our “404” page). Here’s how to do it with ``:
530 |
531 | ```html
532 |
533 |
534 |
535 |
536 |
537 |
538 | ```
539 |
540 | Now, if we’re at `/about`, `` will start looking for a matching ``. `` will match and `` will stop looking for matches and render ``. Similarly, if we’re at `/michael` then `` will render.
541 |
542 | Props:
543 |
544 | ### keepAlive
545 |
546 | - Type: `Boolean`,
547 | - Defaults: `false`
548 |
549 | Weather keep alive the route's components, it will add a `keep-alive` component to wrap the components rendered from matched route.
550 |
551 | If the `router-switch` not remount, all the matched components in it will be cached.
552 |
553 | ```html
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 | ```
568 |
569 | ### location
570 |
571 | - Type: `Location`
572 |
573 | A `location` object to be used for matching children elements instead of the current history location (usually the current browser URL).
574 |
575 | ## ``
576 |
577 | Provides declarative, accessible navigation around your application.
578 |
579 | Props:
580 |
581 | ### to
582 |
583 | - Type: `String | Location`
584 | - Required
585 |
586 | A string representation of the location to link to, created by concatenating the location’s pathname, search, and hash properties.
587 |
588 | Or an object that can have same properties of `Location`.
589 |
590 | ### replace
591 |
592 | - Type: `Boolean`
593 | - Defaults: `false`
594 |
595 | When true, clicking the link will replace the current entry in the history stack instead of adding a new one.
596 |
597 | ### tag
598 |
599 | - Type: `String`,
600 | - Defaults: `'a'`
601 |
602 | Sometimes we want `` to render as another tag, e.g `
`. Then we can use tag prop to specify which tag to render to, and it will still listen to click events for navigation.
603 |
604 | ### exact
605 |
606 | - Type: `Boolean`,
607 | - Defaults: `false`
608 |
609 | When true, the active class will only be applied if the location is matched exactly. See the `` documentation for more information.
610 |
611 | ### strict
612 |
613 | - Type: `Boolean`,
614 | - Defaults: `false`
615 |
616 | When true, the trailing slash on a location’s pathname will be taken into consideration when determining if the location matches the current URL. See the `` documentation for more information.
617 |
618 | ### sensitive
619 |
620 | - Type: `Boolean`,
621 | - Defaults: `true`
622 |
623 | Whether the paths is case sensitive. See the `` documentation for more information.
624 |
625 | ### active-class
626 |
627 | - Type: `String`,
628 | - Defaults: `'router-link-active'`
629 |
630 | Configure the active CSS class applied when the link is active.
631 |
632 | ### exact-active-class
633 |
634 | - Type: `String`,
635 | - Defaults: `'router-link-exact-active'`
636 |
637 | Configure the active CSS class applied when the link is active with exact match.
638 |
639 | ### event
640 |
641 | - Type: `String | String[]`,
642 | - Defaults: `'click'`
643 |
644 | Specify the event(s) that can trigger the link navigation.
645 |
646 | ### location
647 |
648 | - Type: `location`
649 |
650 | The `isActive` compares the current history location (usually the current browser URL). To compare to a different location, a location can be passed.
651 |
652 |
653 | ## history
654 |
655 | The term “history” and "history object" in this documentation refers to the [history package](https://github.com/ReactTraining/history), which is one of only 2 major dependencies of `vue-route-lite`, and which provides several different implementations for managing session history in JavaScript in various environments.
656 |
657 | The following terms are also used:
658 |
659 | - “browser history” - A DOM-specific implementation, useful in web browsers that support the HTML5 history API
660 | - “hash history” - A DOM-specific implementation for legacy web browsers
661 | - “memory history” - An in-memory history implementation, useful in testing and non-DOM environments.
662 |
663 | history objects typically have the following properties and methods:
664 |
665 | - length - (number) The number of entries in the history stack
666 | - action - (string) The current action (PUSH, REPLACE, or POP)
667 | - location - (object) The current location. May have the following properties:
668 | - pathname - (string) The path of the URL
669 | - search - (string) The URL query string
670 | - hash - (string) The URL hash fragment
671 | - state - (object) location-specific state that was provided to e.g. push(path, state) when this location was pushed onto the stack. Only available in browser and memory history.
672 | - push(path, [state]) - (function) Pushes a new entry onto the history stack
673 | - replace(path, [state]) - (function) Replaces the current entry on the history stack
674 | - go(n) - (function) Moves the pointer in the history stack by n entries
675 | - goBack() - (function) Equivalent to go(-1)
676 | - goForward() - (function) Equivalent to go(1)
677 | - block(prompt) - (function) Prevents navigation (see the [history docs](https://github.com/ReactTraining/history#blocking-transitions))
678 |
679 | ### history is mutable
680 |
681 | The history object is mutable. Therefore it is recommended to access the location from the slot props of ``, not from history.location.
682 |
683 | ## location
684 |
685 | Locations represent where the app is now, where you want it to go, or even where it was. It looks like this:
686 |
687 | ```js
688 | {
689 | key: 'ac3df4', // not with HashHistory!
690 | pathname: '/somewhere'
691 | search: '?some=search-string',
692 | hash: '#howdy',
693 | state: {
694 | [userDefined]: true
695 | }
696 | }
697 | ```
698 |
699 | The router will provide you with a location object in a few places:
700 |
701 | - ``
702 | - ``
703 |
704 | ## match
705 |
706 | A match object contains information about how a `` matched the URL. match objects contain the following properties:
707 |
708 | - params - (object) Key/value pairs parsed from the URL corresponding to the dynamic segments of the path
709 | - isExact - (boolean) true if the entire URL was matched (no trailing characters)
710 | - path - (string) The path pattern used to match. Useful for building nested ``s
711 | - url - (string) The matched portion of the URL. Useful for building nested ``s
712 |
713 | You’ll have access to match objects in various places:
714 |
715 | - ``
716 | - ``
717 |
718 | If a Route does not have a path, and therefore always matches, you’ll get the closest parent match. Same goes for withRouter.
719 |
720 | ## createBrowserHistory
721 |
722 | Read `createBrowserHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
723 |
724 | Useful in use with ``
725 |
726 | ## createHashHistory
727 |
728 | Read `createHashHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
729 |
730 | Useful in use with ``
731 |
732 |
733 | ## createMemoryHistory
734 |
735 | Read `createMemoryHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
736 |
737 | Useful in use with ``
738 |
739 | ## createStaticHistory
740 |
741 | Read `createStaticHistory` section on [Hisotry](https://github.com/ReactTraining/history#usage) for more details.
742 |
743 | Useful in use with ``
744 |
745 | ## matchPath
746 |
747 | This lets you use the same matching code that `` uses except outside of the normal render cycle, like gathering up data dependencies before rendering on the server.
748 |
749 | `const match = matchPath(pathname, props)`.
750 |
751 | ```js
752 | import { matchPath } from "vue-router-lite";
753 |
754 | const match = matchPath("/users/123", {
755 | path: "/users/:id",
756 | exact: true,
757 | strict: false,
758 | sensitive: true
759 | });
760 | ```
761 |
762 | ### pathname
763 |
764 | The first argument is the pathname you want to match. If you’re using this on the server with Node.js, it would be req.path.
765 |
766 | ### props
767 |
768 | The second argument are the props to match against, they are identical to the matching props Route accepts:
769 |
770 | ```js
771 | {
772 | path, // like /users/:id; either a single string or an array of strings
773 | strict, // optional, defaults to false
774 | exact, // optional, defaults to false
775 | sensitive, // optional, defaults to true
776 | }
777 | ```
778 |
779 | ### returns
780 |
781 | It returns an object when provided pathname does match path prop or null otherwise.
782 |
783 |
784 | ## generatePath
785 |
786 | generate a path with a `path` and `params`.
787 |
788 | ```js
789 | const pathname = generatePath('/user/:id', { id: 123 });
790 | ```
791 |
792 | Read more details at [path-to-regexp compile](https://github.com/pillarjs/path-to-regexp#compile-reverse-path-to-regexp);
--------------------------------------------------------------------------------
/docs/guide/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | > `vue-router-lite` is a component-based router for vue.js, so all the features of it can do with it's components, just like use ohter general components.
4 |
5 | ## Use Components
6 |
7 | ### Global Registration
8 |
9 | If you use `Vue.use` to `Global Registration` like this, you can use those components directly:
10 |
11 | ```js
12 | import Vue from 'vue'
13 | import VueRouter from 'vue-router-lite'
14 |
15 | // register the components to global
16 | Vue.use(VueRouter)
17 | ```
18 |
19 | It will install itself automatically when using global script tags.
20 |
21 | ### Manual import
22 |
23 | If you use `vue-router-lite` with package tools like `webpack` and `npm`, you can manual import these components and use them.
24 |
25 | ```js
26 | import Vue from 'vue'
27 | import { BrowserRouter, Route, RouterLink, RouteSwitch } from 'vue-router-lite'
28 |
29 | new Vue({
30 | components: {
31 | BrowserRouter,
32 | Route,
33 | RouterLink,
34 | RouteSwitch
35 | }
36 | })
37 | ```
38 |
39 | ## HTML
40 |
41 | ```html
42 |
43 |
44 |
45 |
46 |
47 |
Hello App!
48 |
49 |
50 |
51 |
52 | Go to Foo
53 | Go to Bar
54 | Go to Bar
55 |
56 |
57 |
58 |
59 |
60 |
61 |
Home
62 | matched url: {{ match.url }}
63 |
64 |
65 |
66 |
67 |
About
68 | matched url: {{ match.url }}
69 |
70 |
71 |
72 |
73 |
Other
74 | matched url: {{ match.url }}
75 |
76 |
77 |
78 |
79 |
80 | ```
81 |
82 | ## JavaScript
83 |
84 | ```js
85 | const app = new Vue({
86 | el: '#app'
87 | });
88 | ```
89 |
90 | The ``, ``, ``, ``, ``, `` will use [Scoped Slot Props](https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots) to provide the route info.
91 |
92 | ```html
93 |
94 | ...
95 |
96 | ```
97 |
98 | Notice that a `` automatically gets the .router-link-active class when its target route is matched. You can learn more about it in its [API reference](./api/).
99 |
100 | You can also check out this example [live](https://jsfiddle.net/SeasonChen/akeh2fp7/7/).
--------------------------------------------------------------------------------
/docs/guide/all.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | ## Basic: BrowserRouter
4 |
5 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/basic](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/basic)
6 |
7 | ## HashRouter
8 |
9 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/hash-router](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/hash-router)
10 |
11 | ## MemoryRouter
12 |
13 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/memory-router](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/memory-router)
14 |
15 | ## StaticRouter
16 |
17 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/static-router](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/static-router)
18 |
19 | ## Control History: Router
20 |
21 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/control-history](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/control-history)
22 |
23 | ## URL Parameters
24 |
25 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/url-parameters](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/url-parameters)
26 |
27 | ## Auth Flow And Redirect
28 |
29 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/auth-flow](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/auth-flow)
30 |
31 | ## Chustom Link (Force Render Route)
32 |
33 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/custom-link](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/custom-link)
34 |
35 | ## Preventing Transitions (Prompt)
36 |
37 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/preventing-transitions](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/preventing-transitions)
38 |
39 | ## No Match (404)
40 |
41 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/no-match](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/no-match)
42 |
43 | ## Recursive Paths
44 |
45 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/recursive-paths](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/recursive-paths)
46 |
47 | ## Sidebar
48 |
49 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/sidebar](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/sidebar)
50 |
51 | ## Transitions
52 |
53 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/transitions](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/transitions)
54 |
55 | ## Keep Alive
56 |
57 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/keep-alive](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/keep-alive)
58 |
59 | ## Ambiguous Matches (RouteSwitch)
60 |
61 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/ambiguous-matches](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/ambiguous-matches)
62 |
63 | ## Route Config
64 |
65 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/route-config](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/route-config)
66 |
67 | ## Modal Gallery 1: RouteSwitch
68 |
69 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/modal-gallery](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/modal-gallery)
70 |
71 | ## Modal Gallery 2: path control
72 |
73 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/modal-gallery2](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/modal-gallery2)
74 |
75 | ## Active Links
76 |
77 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/active-links](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/active-links)
78 |
79 | ## Data Fetching
80 |
81 | [https://github.com/ccqgithub/vue-router-lite/tree/master/examples/data-fetching](https://github.com/ccqgithub/vue-router-lite/tree/master/examples/data-fetching)
--------------------------------------------------------------------------------
/docs/guide/control-history.md:
--------------------------------------------------------------------------------
1 | # Control History
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/navigation.md:
--------------------------------------------------------------------------------
1 | # Navigation
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/preventing-transitions.md:
--------------------------------------------------------------------------------
1 | # Preventing Transitions
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/redirects.md:
--------------------------------------------------------------------------------
1 | # Redirects
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/route-info.md:
--------------------------------------------------------------------------------
1 | # Route Info
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/route-matching.md:
--------------------------------------------------------------------------------
1 | # Route Matching
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/guide/routers.md:
--------------------------------------------------------------------------------
1 | # Routers
2 |
3 | todo
--------------------------------------------------------------------------------
/docs/installation.md:
--------------------------------------------------------------------------------
1 | # Installation
2 |
3 | ## Direct Download / CDN
4 |
5 | [https://unpkg.com/vue-router-lite/dist/vue-router-lite.umd.js](https://unpkg.com/vue-router-lite/dist/vue-router-lite.umd.js)
6 |
7 |
8 | [Unpkg.com](https://unpkg.com) provides npm-based CDN links. The above link will always point to the latest release on npm. You can also use a specific version/tag via URLs like `https://unpkg.com/vue-router-lite@1.2.1/dist/vue-router-lite.umd.js`.
9 |
10 |
11 | Include `vue-router-lite` after Vue and it will install itself automatically:
12 |
13 | ``` html
14 |
15 |
16 | ```
17 |
18 | ## Npm
19 |
20 | ``` bash
21 | npm install vue-router-lite
22 | ```
23 |
24 | ## Use
25 |
26 | There are two ways to use the `vue-router-lite`'s components.
27 |
28 | ### `Global Registration` via `Vue.use()`
29 |
30 | > You don't need to do `Vue.use()` when using global script tags.
31 |
32 | ``` js
33 | import Vue from 'vue'
34 | import VueRouter from 'vue-router-lite'
35 |
36 | // register the components to global
37 | Vue.use(VueRouter)
38 |
39 | // then use the components directly
40 | new Vue({
41 | el: '#app',
42 | template: `
43 |
44 |
66 | Sometimes you want to have a whitelist of static paths like "/about" and "/company" but also allow for dynamic patterns like "/:user".
67 | The problem is that "/about" is ambiguous and will match both "/about" and "/:user".
68 | Most routers have an algorithm to decide for you what it will match since they only allow you to match one "route".
69 | Vue Router Lite lets you match in multiple places on purpose (sidebars, breadcrumbs, etc).
70 | So, when you want to clear up any ambiguous matching, and not match "/about" to "/:user", just wrap your <route>s in a <route-switch>.
71 | It will render the first one that matches.
72 |