Skip to content

Commit 40fe605

Browse files
committed
Import Vue-Router w/ router-link practice
1 parent 04b1edc commit 40fe605

File tree

10 files changed

+2090
-790
lines changed

10 files changed

+2090
-790
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
},
1010
"dependencies": {
1111
"core-js": "^2.6.5",
12-
"element-ui": "^2.11.1",
13-
"vue": "^2.6.10"
12+
"element-ui": "^2.13.0",
13+
"vue": "^2.6.10",
14+
"vue-router": "^3.1.5"
1415
},
1516
"devDependencies": {
1617
"@vue/cli-plugin-babel": "^3.9.0",
1718
"@vue/cli-plugin-eslint": "^3.9.0",
18-
"@vue/cli-service": "^3.9.0",
19+
"@vue/cli-service": "^4.2.2",
1920
"babel-eslint": "^10.0.1",
2021
"eslint": "^5.16.0",
2122
"eslint-plugin-vue": "^5.0.0",

src/App.vue

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
<template>
22
<div id="app">
33
<img src="./assets/logo.png">
4-
<div>
5-
<!--
6-
<p>
7-
If Element is successfully added to this project, you'll see an
8-
<code v-text="'<el-button>'"></code>
9-
below
10-
</p>
11-
<el-button>el-button</el-button>
12-
<div style = "font-size: 30px;">Heading: FHDATime</div>
13-
-->
14-
</div>
15-
16-
<HelloWorld msg="FHDATime"/>
17-
4+
<!-- <HelloWorld msg="FHDATime"/> -->
5+
<!-- <p>dsnaksndlas</p> -->
6+
<ul>
7+
<li><router-link to="/">Home</router-link></li>
8+
<li><router-link to="/Contact">Contact</router-link></li>
9+
<li><router-link to="/About">About</router-link></li>
10+
</ul>
11+
<router-view/>
1812
</div>
1913
</template>
2014

2115
<script>
22-
import HelloWorld from './components/HelloWorld.vue'
23-
16+
// import HelloWorld from './components/HelloWorld.vue'
17+
2418
2519
export default {
2620
name: 'app',
27-
components: {
28-
HelloWorld
29-
}
21+
// components: {
22+
// HelloWorld
23+
// }
3024
}
25+
// export default {
26+
// name: 'App'
27+
// }
3128
</script>
3229

3330
<style>

src/components/About.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<h1>About us</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
8+
}
9+
</script>

src/components/Contact.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<h1>Contact us</h1>
3+
</template>
4+
5+
<script>
6+
export default {
7+
8+
}
9+
</script>

src/components/FirstRoute.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
Hello {{ $route.params.name }}
5+
<router-view>
6+
</router-view>
7+
</div>
8+
</template>
9+
10+
<script>
11+
export default {
12+
name: 'FirstRoute',
13+
data () {
14+
return {
15+
msg: 'First Route Page'
16+
}
17+
}
18+
}
19+
</script>
20+
21+
<!-- Add "scoped" attribute to limit CSS to this component only -->
22+
<style scoped>
23+
h1, h2 {
24+
font-weight: normal;
25+
}
26+
ul {
27+
list-style-type: none;
28+
padding: 0;
29+
}
30+
li {
31+
display: inline-block;
32+
margin: 0 10px;
33+
}
34+
a {
35+
color: #42b983;
36+
}
37+
</style>

src/components/FirstRouteChild.vue

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
5+
</div>
6+
</template>
7+
8+
<script>
9+
export default {
10+
name: 'FirstRouteChild',
11+
data () {
12+
return {
13+
msg: 'FirstRouteChild Page'
14+
}
15+
}
16+
}
17+
</script>
18+
19+
<!-- Add "scoped" attribute to limit CSS to this component only -->
20+
<style scoped>
21+
h1, h2 {
22+
font-weight: normal;
23+
}
24+
ul {
25+
list-style-type: none;
26+
padding: 0;
27+
}
28+
li {
29+
display: inline-block;
30+
margin: 0 10px;
31+
}
32+
a {
33+
color: #42b983;
34+
}
35+
</style>

src/components/HelloWorld.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<h1>{{ msg }}</h1>
55

66
<el-row>
7-
87
Select quarter:
98
<el-button class='focus' v-on:click="setQtr('Fall')">Fall</el-button>
109
<el-button class='focus' v-on:click="setQtr('Winter')">Winter</el-button>
@@ -39,16 +38,17 @@
3938
4039
export default {
4140
name: 'HelloWorld',
42-
props: {
43-
msg: String
44-
},
41+
// props: {
42+
// msg: String
43+
// },
4544
methods:{
4645
setQtr(quarterName) {
4746
this.quarter = quarterName
4847
}
4948
},
5049
data() {
5150
return {
51+
// msg: 'FHDATIME',
5252
quarter: '',
5353
course: '',
5454
departmentOptions:
@@ -495,10 +495,10 @@ export default {
495495
<!-- Add "scoped" attribute to limit CSS to this component only -->
496496
<style scoped>
497497
498-
body {
498+
/* body {
499499
background-color: #b8032c;
500-
/* padding: 50px; */
501-
}
500+
padding: 50px;
501+
} */
502502
503503
h3 {
504504
margin: 40px 0 0;
@@ -524,8 +524,8 @@ a {
524524
}
525525
526526
.focus:focus {
527-
/* color: darkcyan; */
528-
color: red;
527+
color: darkcyan;
528+
/* color: red; */
529529
}
530530
531531

src/components/Home.vue

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
<HelloWorld/>
5+
6+
7+
8+
</div>
9+
</template>
10+
11+
<script>
12+
13+
import HelloWorld from '@/components/HelloWorld'
14+
15+
16+
export default {
17+
name: 'Home',
18+
components: {
19+
HelloWorld
20+
},
21+
data () {
22+
return {
23+
msg: 'FHDATIME'
24+
}
25+
}
26+
}
27+
</script>
28+
29+
<!-- Add "scoped" attribute to limit CSS to this component only -->
30+
<style scoped>
31+
h1, h2 {
32+
font-weight: normal;
33+
}
34+
ul {
35+
list-style-type: none;
36+
padding: 0;
37+
}
38+
li {
39+
display: inline-block;
40+
margin: 0 10px;
41+
}
42+
a {
43+
color: #42b983;
44+
}
45+
</style>

src/main.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,53 @@
11
import Vue from 'vue'
2+
import Router from 'vue-router'
23
import App from './App.vue'
34

5+
Vue.use(Router)
6+
7+
// import HelloWorld from './components/HelloWorld.vue'
8+
import Home from '@/components/Home'
9+
import About from '@/components/About'
10+
import Contact from '@/components/Contact'
11+
// import FirstRoute from '@/components/FirstRoute'
12+
// import FirstRouteChild from '@/components/FirstRouteChild'
13+
414
import ElementUI from 'element-ui'
515
import 'element-ui/lib/theme-chalk/index.css'
616
import './plugins/element.js'
717
Vue.use(ElementUI)
818

919
Vue.config.productionTip = false
1020

21+
const router = new Router({
22+
routes: [
23+
{
24+
path: '/',
25+
name: 'Home',
26+
component: Home
27+
},
28+
{
29+
path: '/About',
30+
name: 'About',
31+
component: About
32+
},
33+
{
34+
path: '/Contact',
35+
name: 'Contact',
36+
component: Contact
37+
}
38+
]
39+
})
40+
41+
1142
new Vue({
1243
render: h => h(App),
44+
router
1345
}).$mount('#app')
1446

47+
// new Vue({
48+
// el: '#app',
49+
// Router,
50+
// components: { App },
51+
// template: '<App/>'
52+
// })
53+

0 commit comments

Comments
 (0)