From cafcf81cbcfc3667d5360208cf9a984cf506a243 Mon Sep 17 00:00:00 2001 From: gwen Date: Mon, 26 Feb 2024 16:20:39 +0100 Subject: [PATCH] mettre routes dans main.js et creer testparametreurl --- .../src/components/TestParametreURL.vue | 3 +++ science-quest/src/main.js | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 science-quest/src/components/TestParametreURL.vue diff --git a/science-quest/src/components/TestParametreURL.vue b/science-quest/src/components/TestParametreURL.vue new file mode 100644 index 0000000..718f888 --- /dev/null +++ b/science-quest/src/components/TestParametreURL.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/science-quest/src/main.js b/science-quest/src/main.js index 0ac3a5f..d8c433a 100644 --- a/science-quest/src/main.js +++ b/science-quest/src/main.js @@ -1,6 +1,25 @@ import './assets/main.css' +import { createRouter, createWebHashHistory } from 'vue-router' import { createApp } from 'vue' import App from './App.vue' -createApp(App).mount('#app') +//importer les components pour le routing +import PagePrincipale from "./components/PagePrincipale.vue" +import NotFound from "./components/erreurs/NotFound.vue" +import TestParametreURL from "./components/TestParametreURL.vue" + +const routes = [ + { path: '/', component: PagePrincipale }, + { path: '/exemple/:id', component: TestParametreURL }, + { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound }, +] + +const router = createRouter({ + // 4. Provide the history implementation to use. We + // are using the hash history for simplicity here. + history: createWebHashHistory(), + routes, // short for `routes: routes` +}) + +createApp(App).use(router).mount('#app')