Skip to content

Commit 4ac14ee

Browse files
committed
Add vue router
1 parent 1541552 commit 4ac14ee

File tree

10 files changed

+61
-84
lines changed

10 files changed

+61
-84
lines changed

docs/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.6.4",
12-
"vue": "^2.6.11"
12+
"vue": "^2.6.11",
13+
"vue-router": "^3.1.6"
1314
},
1415
"devDependencies": {
1516
"@vue/cli-plugin-babel": "~4.3.0",
1617
"@vue/cli-plugin-eslint": "~4.3.0",
18+
"@vue/cli-plugin-router": "^4.3.0",
1719
"@vue/cli-service": "~4.3.0",
1820
"babel-eslint": "^10.1.0",
1921
"eslint": "^6.7.2",

docs/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/uikit.min.css" />
78
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
89
<title><%= htmlWebpackPlugin.options.title %></title>
910
</head>

docs/src/App.vue

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
11
<template>
22
<div id="app">
3-
<img alt="Vue logo" src="./assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js App"/>
3+
<div id="nav">
4+
<router-link to="/">Home</router-link> |
5+
<router-link to="/about">About</router-link>
6+
</div>
7+
<router-view/>
58
</div>
69
</template>
7-
8-
<script>
9-
import HelloWorld from './components/HelloWorld.vue'
10-
11-
export default {
12-
name: 'App',
13-
components: {
14-
HelloWorld
15-
}
16-
}
17-
</script>
18-
19-
<style>
20-
#app {
21-
font-family: Avenir, Helvetica, Arial, sans-serif;
22-
-webkit-font-smoothing: antialiased;
23-
-moz-osx-font-smoothing: grayscale;
24-
text-align: center;
25-
color: #2c3e50;
26-
margin-top: 60px;
27-
}
28-
</style>

docs/src/assets/logo.png

-6.69 KB
Binary file not shown.

docs/src/components/HelloWorld.vue

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import Vue from 'vue'
22
import App from './App.vue'
3+
import router from './router'
34

45
Vue.config.productionTip = false
56

67
new Vue({
7-
render: h => h(App),
8+
router,
9+
render: h => h(App)
810
}).$mount('#app')

docs/src/router/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Vue from 'vue'
2+
import VueRouter from 'vue-router'
3+
import Home from '../views/Home.vue'
4+
5+
Vue.use(VueRouter)
6+
7+
const routes = [
8+
{
9+
path: '/',
10+
name: 'Home',
11+
component: Home
12+
},
13+
{
14+
path: '/about',
15+
name: 'About',
16+
// route level code-splitting
17+
// this generates a separate chunk (about.[hash].js) for this route
18+
// which is lazy-loaded when the route is visited.
19+
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
20+
}
21+
]
22+
23+
const router = new VueRouter({
24+
routes
25+
})
26+
27+
export default router

docs/src/views/About.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div class="about">
3+
<h1>This is an about page</h1>
4+
</div>
5+
</template>

docs/src/views/Home.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<div class="home">
3+
</div>
4+
</template>
5+
6+
<script>
7+
export default {
8+
name: 'Home',
9+
components: {
10+
}
11+
}
12+
</script>

0 commit comments

Comments
 (0)