Feat: basic routing

This commit is contained in:
Bertrand Benjamin 2021-06-08 23:32:04 +02:00
parent 28a58c43db
commit e0d4ff6cc6
9 changed files with 72 additions and 23 deletions

33
package-lock.json generated
View File

@ -10,7 +10,7 @@
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "core-js": "^3.6.5",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^3.5.1" "vue-router": "^4.0.8"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "~4.5.0",
@ -2901,6 +2901,11 @@
"dev": true, "dev": true,
"license": "ISC" "license": "ISC"
}, },
"node_modules/@vue/devtools-api": {
"version": "6.0.0-beta.13",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.0.0-beta.13.tgz",
"integrity": "sha512-oZ0n/N4UWpkMvbR1OrBtu+YhaVADo+bYX5lxo9tou7h10p0+v2K9yzzaZATVr0lqHb7iY1wALfO8yojwg0MTHw=="
},
"node_modules/@vue/preload-webpack-plugin": { "node_modules/@vue/preload-webpack-plugin": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz", "resolved": "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz",
@ -18357,9 +18362,15 @@
} }
}, },
"node_modules/vue-router": { "node_modules/vue-router": {
"version": "3.5.1", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.8.tgz",
"integrity": "sha512-RRQNLT8Mzr8z7eL4p7BtKvRaTSGdCbTy2+Mm5HTJvLGYSSeG9gDzNasJPP/yOYKLy+/cLG/ftrqq5fvkFwBJEw==" "integrity": "sha512-42mWSQaH7CCBQDspQTHv63f34VEnZC20g9QNK4WJ/zW8SdIUeT6TQ2i/78fjF/pVBUPLBWrGhvB7uDnaz7O/pA==",
"dependencies": {
"@vue/devtools-api": "^6.0.0-beta.10"
},
"peerDependencies": {
"vue": "^3.0.0"
}
}, },
"node_modules/vue-style-loader": { "node_modules/vue-style-loader": {
"version": "4.1.3", "version": "4.1.3",
@ -21468,6 +21479,11 @@
} }
} }
}, },
"@vue/devtools-api": {
"version": "6.0.0-beta.13",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.0.0-beta.13.tgz",
"integrity": "sha512-oZ0n/N4UWpkMvbR1OrBtu+YhaVADo+bYX5lxo9tou7h10p0+v2K9yzzaZATVr0lqHb7iY1wALfO8yojwg0MTHw=="
},
"@vue/preload-webpack-plugin": { "@vue/preload-webpack-plugin": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz", "resolved": "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz",
@ -33077,9 +33093,12 @@
} }
}, },
"vue-router": { "vue-router": {
"version": "3.5.1", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.8.tgz",
"integrity": "sha512-RRQNLT8Mzr8z7eL4p7BtKvRaTSGdCbTy2+Mm5HTJvLGYSSeG9gDzNasJPP/yOYKLy+/cLG/ftrqq5fvkFwBJEw==" "integrity": "sha512-42mWSQaH7CCBQDspQTHv63f34VEnZC20g9QNK4WJ/zW8SdIUeT6TQ2i/78fjF/pVBUPLBWrGhvB7uDnaz7O/pA==",
"requires": {
"@vue/devtools-api": "^6.0.0-beta.10"
}
}, },
"vue-style-loader": { "vue-style-loader": {
"version": "4.1.3", "version": "4.1.3",

View File

@ -15,7 +15,7 @@
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "core-js": "^3.6.5",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^3.5.1" "vue-router": "^4.0.8"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "~4.5.0",

View File

@ -1,16 +1,14 @@
<template> <template>
<Nav></Nav> <Nav></Nav>
<Content></Content> <router-view></router-view>
</template> </template>
<script> <script>
import Content from './components/content.vue'
import Nav from './components/nav.vue' import Nav from './components/nav.vue'
export default { export default {
name: 'App', name: 'App',
components: { components: {
Content,
Nav Nav
} }
} }

View File

@ -1,9 +1,7 @@
<template> <template>
<nav> <nav>
<ul> <router-link to="/"> Home </router-link>
<li>Plop</li> <router-link to="/config"> Config </router-link>
<li>Pipo</li>
</ul>
</nav> </nav>
</template> </template>

View File

@ -1,7 +1,8 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import VueRouter from "vue-router" import App from '@/App.vue'
import App from './App.vue' import router from '@/router'
vue.use(VueRouter)
createApp(App).mount('#app') const app = createApp(App)
app.use(router)
app.mount('#app')

20
src/router.js Normal file
View File

@ -0,0 +1,20 @@
import { createRouter, createWebHistory } from 'vue-router'
import Home from "@/views/home.vue"
import Config from "@/views/config.vue"
const routes = [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/config',
name: 'config',
component: Config
}
]
const router = createRouter({ history: createWebHistory(), routes })
export default router

3
src/views/config.vue Normal file
View File

@ -0,0 +1,3 @@
<template>
<h1>Config</h1>
</template>

3
src/views/home.vue Normal file
View File

@ -0,0 +1,3 @@
<template>
<h1>Home</h1>
</template>

View File

@ -1532,6 +1532,11 @@
optionalDependencies: optionalDependencies:
"prettier" "^1.18.2" "prettier" "^1.18.2"
"@vue/devtools-api@^6.0.0-beta.10":
"integrity" "sha512-oZ0n/N4UWpkMvbR1OrBtu+YhaVADo+bYX5lxo9tou7h10p0+v2K9yzzaZATVr0lqHb7iY1wALfO8yojwg0MTHw=="
"resolved" "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.0.0-beta.13.tgz"
"version" "6.0.0-beta.13"
"@vue/preload-webpack-plugin@^1.1.0": "@vue/preload-webpack-plugin@^1.1.0":
"integrity" "sha512-LIZMuJk38pk9U9Ur4YzHjlIyMuxPlACdBIHH9/nGYVTsaGKOSnSuELiE8vS9wa+dJpIYspYUOqk+L1Q4pgHQHQ==" "integrity" "sha512-LIZMuJk38pk9U9Ur4YzHjlIyMuxPlACdBIHH9/nGYVTsaGKOSnSuELiE8vS9wa+dJpIYspYUOqk+L1Q4pgHQHQ=="
"resolved" "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz" "resolved" "https://registry.npmjs.org/@vue/preload-webpack-plugin/-/preload-webpack-plugin-1.1.2.tgz"
@ -9856,10 +9861,12 @@
"vue-hot-reload-api" "^2.3.0" "vue-hot-reload-api" "^2.3.0"
"vue-style-loader" "^4.1.0" "vue-style-loader" "^4.1.0"
"vue-router@^3.5.1": "vue-router@^4.0.8":
"integrity" "sha512-RRQNLT8Mzr8z7eL4p7BtKvRaTSGdCbTy2+Mm5HTJvLGYSSeG9gDzNasJPP/yOYKLy+/cLG/ftrqq5fvkFwBJEw==" "integrity" "sha512-42mWSQaH7CCBQDspQTHv63f34VEnZC20g9QNK4WJ/zW8SdIUeT6TQ2i/78fjF/pVBUPLBWrGhvB7uDnaz7O/pA=="
"resolved" "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz" "resolved" "https://registry.npmjs.org/vue-router/-/vue-router-4.0.8.tgz"
"version" "3.5.1" "version" "4.0.8"
dependencies:
"@vue/devtools-api" "^6.0.0-beta.10"
"vue-style-loader@^4.1.0", "vue-style-loader@^4.1.2": "vue-style-loader@^4.1.0", "vue-style-loader@^4.1.2":
"integrity" "sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg==" "integrity" "sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg=="