diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 5e676d4..25eec74 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -11137,6 +11137,11 @@ } } }, + "vue-router": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.1.6.tgz", + "integrity": "sha512-GYhn2ynaZlysZMkFE5oCHRUTqE8BWs/a9YbKpNLi0i7xD6KG1EzDqpHQmv1F5gXjr8kL5iIVS8EOtRaVUEXTqA==" + }, "vue-style-loader": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index 44f0fd7..e9bddbc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,7 +9,8 @@ }, "dependencies": { "core-js": "^3.6.4", - "vue": "^2.6.11" + "vue": "^2.6.11", + "vue-router": "^3.1.6" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.3.0", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 55df315..50c20bc 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,21 +1,14 @@ - - + + Home | + About | + Profile + + - - diff --git a/frontend/src/components/HelloWorld.vue b/frontend/src/components/HelloWorld.vue deleted file mode 100644 index 879051a..0000000 --- a/frontend/src/components/HelloWorld.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - {{ msg }} - - For a guide and recipes on how to configure / customize this project, - check out the - vue-cli documentation. - - Installed CLI Plugins - - babel - eslint - - Essential Links - - Core Docs - Forum - Community Chat - Twitter - News - - Ecosystem - - vue-router - vuex - vue-devtools - vue-loader - awesome-vue - - - - - - - - diff --git a/frontend/src/main.js b/frontend/src/main.js index 63eb05f..1f5f073 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -1,8 +1,10 @@ -import Vue from 'vue' -import App from './App.vue' +import Vue from "vue"; +import App from "./App.vue"; +import router from "./router"; -Vue.config.productionTip = false +Vue.config.productionTip = false; new Vue({ - render: h => h(App), -}).$mount('#app') + router, + render: h => h(App) +}).$mount("#app"); diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js new file mode 100644 index 0000000..4178a7a --- /dev/null +++ b/frontend/src/router/index.js @@ -0,0 +1,53 @@ +import Vue from "vue"; +import VueRouter from "vue-router"; +import Home from "../views/Home.vue"; +import Profile from "../views/profile.vue"; +import missing from "../views/missing.vue"; +import Info from "../views/Info.vue"; +Vue.use(VueRouter); + +const routes = [ + { + path: "/", + name: "Home", + component: Home + }, + { + path: "/profile/:id", + name: "Profile", + component: Profile, + children: [ + { + path: 'info', + name: 'Info', + component: Info + } + ] + }, + { + path: "/profile", + name: "ProfileMain", + component: Profile + }, + { + path: "/about", + name: "About", + // route level code-splitting + // this generates a separate chunk (about.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => + import(/* webpackChunkName: "about" */ "../views/About.vue") + }, + { + path: '*', + component: missing + } +]; + +const router = new VueRouter({ + mode: "history", + base: process.env.BASE_URL, + routes +}); + +export default router; diff --git a/frontend/src/views/About.vue b/frontend/src/views/About.vue new file mode 100644 index 0000000..3fa2807 --- /dev/null +++ b/frontend/src/views/About.vue @@ -0,0 +1,5 @@ + + + This is an about page + + diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue new file mode 100644 index 0000000..04585b4 --- /dev/null +++ b/frontend/src/views/Home.vue @@ -0,0 +1,18 @@ + + + + Home View + + + + diff --git a/frontend/src/views/Info.vue b/frontend/src/views/Info.vue new file mode 100644 index 0000000..ab66faf --- /dev/null +++ b/frontend/src/views/Info.vue @@ -0,0 +1,17 @@ + + + info + + + + + + diff --git a/frontend/src/views/missing.vue b/frontend/src/views/missing.vue new file mode 100644 index 0000000..2a77a89 --- /dev/null +++ b/frontend/src/views/missing.vue @@ -0,0 +1,13 @@ + + Errror 404 + + + + + diff --git a/frontend/src/views/profile.vue b/frontend/src/views/profile.vue new file mode 100644 index 0000000..3355b07 --- /dev/null +++ b/frontend/src/views/profile.vue @@ -0,0 +1,27 @@ + + + My profile + {{$route.params.id}} + Another Route + + Info + {{$route.query}} + + + + + + + +
- For a guide and recipes on how to configure / customize this project, - check out the - vue-cli documentation. -