Feat: basic routing

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

View File

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

View File

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

View File

@@ -1,7 +1,8 @@
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>