Commit af1ebca7e329cee791f095f4135cb991512fae62
1 parent
c3a08746
update router not found
Showing
3 changed files
with
19 additions
and
13 deletions
dist.zip deleted
100644 → 0
No preview for this file type
index.html
@@ -12,6 +12,16 @@ | @@ -12,6 +12,16 @@ | ||
12 | "> | 12 | "> |
13 | </head> | 13 | </head> |
14 | 14 | ||
15 | +<!-- Google tag (gtag.js) --> | ||
16 | +<script async src="https://www.googletagmanager.com/gtag/js?id=AW-881504701"></script> | ||
17 | +<script> | ||
18 | + window.dataLayer = window.dataLayer || []; | ||
19 | + function gtag() { dataLayer.push(arguments); } | ||
20 | + gtag('js', new Date()); | ||
21 | + | ||
22 | + gtag('config', 'AW-881504701'); | ||
23 | +</script> | ||
24 | + | ||
15 | <body> | 25 | <body> |
16 | <div id="app"></div> | 26 | <div id="app"></div> |
17 | <script type="module" src="/src/main.ts"></script> | 27 | <script type="module" src="/src/main.ts"></script> |
src/router/index.ts
@@ -13,11 +13,6 @@ const router = createRouter({ | @@ -13,11 +13,6 @@ const router = createRouter({ | ||
13 | history: createWebHistory(import.meta.env.BASE_URL), | 13 | history: createWebHistory(import.meta.env.BASE_URL), |
14 | routes: [ | 14 | routes: [ |
15 | { | 15 | { |
16 | - path: '/index', | ||
17 | - name: 'index', | ||
18 | - redirect: '/' | ||
19 | - }, | ||
20 | - { | ||
21 | path: '/', | 16 | path: '/', |
22 | name: 'home', | 17 | name: 'home', |
23 | component: Home, | 18 | component: Home, |
@@ -129,15 +124,16 @@ const router = createRouter({ | @@ -129,15 +124,16 @@ const router = createRouter({ | ||
129 | } | 124 | } |
130 | } | 125 | } |
131 | } | 126 | } |
132 | - // { | ||
133 | - // path: '/about', | ||
134 | - // name: 'about', | ||
135 | - // // route level code-splitting | ||
136 | - // // this generates a separate chunk (About.[hash].js) for this route | ||
137 | - // // which is lazy-loaded when the route is visited. | ||
138 | - // // component: () => import('../views/AboutView.vue') | ||
139 | - // } | ||
140 | ] | 127 | ] |
141 | }) | 128 | }) |
142 | 129 | ||
130 | +router.beforeEach((to, from, next) => { | ||
131 | + // not found redirect home | ||
132 | + if (to.matched.length === 0) { | ||
133 | + next('/') | ||
134 | + } else { | ||
135 | + next() | ||
136 | + } | ||
137 | +}) | ||
138 | + | ||
143 | export default router | 139 | export default router |