add first routing draft

This commit is contained in:
Rene Fischer 2020-05-22 17:05:34 +02:00
parent 5dca366f97
commit ad46e09482
8 changed files with 88 additions and 29 deletions

5
package-lock.json generated
View file

@ -11389,6 +11389,11 @@
}
}
},
"vue-router": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.2.0.tgz",
"integrity": "sha512-khkrcUIzMcI1rDcNtqkvLwfRFzB97GmJEsPAQdj7t/VvpGhmXLOkUfhc+Ah8CvpSXGXwuWuQO+x8Sy/xDhXZIA=="
},
"vue-style-loader": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",

View file

@ -10,11 +10,13 @@
"dependencies": {
"core-js": "^3.6.4",
"pwa": "^1.9.7",
"vue": "^2.6.11"
"vue": "^2.6.11",
"vue-router": "^3.1.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-router": "^4.3.1",
"@vue/cli-service": "~4.3.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",

View file

@ -1,34 +1,9 @@
<template>
<div id="app">
<DeckSelection title="Fancy Flashcard" v-bind:decks="decks"></DeckSelection>
<router-view />
</div>
</template>
<script>
import DeckSelection from './components/deckselection/DeckSelection.vue'
export default {
name: 'App',
components: {
DeckSelection
},
data() {
return {
decks: [
{
id: 1,
deckname: "Test1"
},
{
id: 2,
deckname: "Test2"
}
]
};
},
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
@ -36,6 +11,5 @@ export default {
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>

View file

@ -7,6 +7,8 @@
<Deck v-for="deck in decks" :key="deck.id" v-bind:deckname="deck.deckname"></Deck>
<input type="submit" value="Starten" />
</form>
<hr>
<router-link to="/about">Example Routing - About</router-link>
</div>
</template>

View file

@ -1,8 +1,10 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
router,
render: h => h(App)
}).$mount('#app')

29
src/router/index.js Normal file
View file

@ -0,0 +1,29 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Deckselection',
component: Home
},
{
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')
}
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router

5
src/views/About.vue Normal file
View file

@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

40
src/views/Home.vue Normal file
View file

@ -0,0 +1,40 @@
<template>
<div class="deckselection">
<DeckSelection title="Fancy Flashcard" v-bind:decks="decks"></DeckSelection>
</div>
</template>
<script>
import DeckSelection from '../components/deckselection/DeckSelection.vue'
export default {
name: 'App',
components: {
DeckSelection
},
data() {
return {
decks: [
{
id: 1,
deckname: "Test1"
},
{
id: 2,
deckname: "Test2"
}
]
};
},
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>