Skip to content

Commit b03b9d8

Browse files
2 parents 16066fd + 3d7196b commit b03b9d8

File tree

3 files changed

+53
-43
lines changed

3 files changed

+53
-43
lines changed

content/.vitepress/config.mts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
2121
export default defineConfig({
2222
lang: 'en-US',
2323
title: 'Vue Cheatsheet',
24+
lastUpdated: true,
2425
description: "The one and only cheatsheet you need for Vue.js by ThemeSelection",
2526
head: [
2627
['link', { rel: 'icon', href: '/logos/favicon.ico' }],
@@ -92,6 +93,10 @@ export default defineConfig({
9293
{ icon: 'github', link: 'https://github.com/themeselection/vue-cheatsheet' },
9394
{ icon: 'twitter', link: 'https://twitter.com/Theme_Selection' }
9495
],
96+
97+
editLink: {
98+
pattern: 'https://github.com/themeselection/vue-cheatsheet/edit/main/content/:path'
99+
}
95100
},
96101
vite: {
97102
resolve: {

content/vue-router/basic.md

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const router = createRouter({
1010
routes: [
1111
{
1212
path: '/',
13-
name: 'home',
14-
component: () => import('./views/HomeView.vue')
13+
name: 'home', // "home" will be route name
14+
component: () => import('./views/HomeView.vue') // Always lazy load route components
1515
},
1616
{
1717
path: '/about',
@@ -28,12 +28,49 @@ Use `RouterView` to render the matched component for the current route, and use
2828
<template>
2929
<nav>
3030
<RouterLink to="/">Home</RouterLink>
31-
<RouterLink :to="{ name: 'about' }">About</RouterLink> <!-- Named Routes -->
31+
32+
<!-- Use route name via object syntax -->
33+
<RouterLink :to="{ name: 'about' }">About</RouterLink>
3234
</nav>
3335
<RouterView />
3436
</template>
3537
```
3638

39+
## Programmatic Navigation
40+
41+
Aside from using `<RouterLink>` to create anchor tags for declarative navigation, we can do this programmatically using the router's instance methods.
42+
43+
| Declarative | Programmatic |
44+
| ------------- | :-----------: |
45+
| `<RouterLink :to="...">` | `router.push(...)` |
46+
| `<RouterLink :to="..." replace>` | `router.replace(...)` |
47+
| `window.history.go(n)` | `router.go(1)` |
48+
49+
The argument can be a string path, or a location descriptor object.
50+
51+
```ts
52+
// literal string path
53+
router.push('/users/eduardo')
54+
55+
// object with path
56+
router.push({ path: '/users/eduardo' })
57+
58+
// named route with params to let the router build the url
59+
router.push({ name: 'user', params: { username: 'eduardo' } })
60+
61+
// with query, resulting in /register?plan=private
62+
router.replace({ path: '/register', query: { plan: 'private' } })
63+
64+
// with hash, resulting in /about#team
65+
router.replace({ path: '/about', hash: '#team' })
66+
67+
// go forward by one record, the same as router.forward()
68+
router.go(1)
69+
70+
// go back by one record, the same as router.back()
71+
router.go(-1)
72+
```
73+
3774
## Dynamic Routing
3875

3976
Dynamic routes are used to match a series of routes with some params to be acquired. (Denoted by **colon** `:` )
@@ -177,41 +214,6 @@ const router = createRouter({
177214
</template>
178215
```
179216

180-
## Programmatic Navigation
181-
182-
Aside from using `<RouterLink>` to create anchor tags for declarative navigation, we can do this programmatically using the router's instance methods.
183-
184-
| Declarative | Programmatic |
185-
| ------------- | :-----------: |
186-
| `<RouterLink :to="...">` | `router.push(...)` |
187-
| `<RouterLink :to="..." replace>` | `router.replace(...)` |
188-
| `window.history.go(n)` | `router.go(1)` |
189-
190-
The argument can be a string path, or a location descriptor object.
191-
192-
```ts
193-
// literal string path
194-
router.push('/users/eduardo')
195-
196-
// object with path
197-
router.push({ path: '/users/eduardo' })
198-
199-
// named route with params to let the router build the url
200-
router.push({ name: 'user', params: { username: 'eduardo' } })
201-
202-
// with query, resulting in /register?plan=private
203-
router.replace({ path: '/register', query: { plan: 'private' } })
204-
205-
// with hash, resulting in /about#team
206-
router.replace({ path: '/about', hash: '#team' })
207-
208-
// go forward by one record, the same as router.forward()
209-
router.go(1)
210-
211-
// go back by one record, the same as router.back()
212-
router.go(-1)
213-
```
214-
215217
## Named Views
216218

217219
```ts
@@ -304,16 +306,19 @@ const User = {
304306
305307
const routes = [
306308
// Boolean mode
307-
{ path: '/user/:id',
309+
{
310+
path: '/user/:id',
308311
component: User,
309312
props: true
310313
},
314+
311315
// Object mode
312316
{
313317
path: '/user/:id',
314318
components: { default: User, sidebar: Sidebar },
315319
props: { default: true, sidebar: false }
316320
},
321+
317322
// Function mode
318323
{
319324
path: '/search',

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ If you want to [Download Free Admin Templates](https://themeselection.com/produc
6464

6565
## Social Media 😇
6666

67-
- Twitter : [https://twitter.com/themeselect](https://twitter.com/themeselect)
68-
- Facebook : [https://www.facebook.com/ThemeSelections/](https://www.facebook.com/ThemeSelections/)
69-
- Pintrest : [https://pinterest.com/themeselect/](https://pinterest.com/themeselect/)
70-
- Instagram : [https://www.instagram.com/themeselect_official/](https://www.instagram.com/themeselect_official/)
67+
- Twitter : [https://twitter.com/Theme_Selection](https://twitter.com/Theme_Selection)
68+
- Facebook : [https://www.facebook.com/ThemeSelections](https://www.facebook.com/ThemeSelections/)
69+
- Pintrest : [https://www.pinterest.com/themeselection/](https://www.pinterest.com/themeselection/)
70+
- Instagram : [https://www.instagram.com/themeselection/](https://www.instagram.com/themeselection/)

0 commit comments

Comments
 (0)