]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: mention abstract history mode in the guide
authorRalph van Kruiselbergen <mail@ralphvankruiselbergen.nl>
Mon, 9 May 2022 17:47:16 +0000 (19:47 +0200)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 12 May 2022 09:14:34 +0000 (11:14 +0200)
docs/guide/essentials/history-mode.md

index d0e95a67d3af85d42f9cd81315609db207e2edd5..d320519377002973ad5481a20d4497bcd4ea4a64 100644 (file)
@@ -45,6 +45,22 @@ Here comes a problem, though: Since our app is a single page client side app, wi
 
 Not to worry: To fix the issue, all you need to do is add a simple catch-all fallback route to your server. If the URL doesn't match any static assets, it should serve the same `index.html` page that your app lives in. Beautiful, again!
 
+## Abstract mode
+
+The abstract history mode is created with `createMemoryHistory()`:
+
+```js
+import { createRouter, createMemoryHistory } from 'vue-router'
+const router = createRouter({
+  history: createMemoryHistory(),
+  routes: [
+    //...
+  ],
+})
+```
+
+When using `createMemoryHistory()` the URL will not change when navigating between routes and no entries will be created in the browser history. The history is kept "hidden" within the javascript. The history will not persist when leaving or reloading the app, you get a fresh start every time your app is reloaded. Vue Router will always try to resolve the root `'/'` path when the app is loaded.
+
 ## Example Server Configurations
 
 **Note**: The following examples assume you are serving your app from the root folder. If you deploy to a subfolder, you should use [the `publicPath` option of Vue CLI](https://cli.vuejs.org/config/#publicpath) and the related [`base` property of the router](../../api/#createwebhistory). You also need to adjust the examples below to use the subfolder instead of the root folder (e.g. replacing `RewriteBase /` with `RewriteBase /name-of-your-subfolder/`).