Skip to content

Commit f59f94f

Browse files
author
Shaun Pelling
committed
added lesson 16 code
1 parent 488233d commit f59f94f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

app.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
Vue.component('greeting', {
2-
template: '<p>Hey there, I am a re-usable component</p>'
3-
});
4-
51
new Vue({
6-
el: '.vue-app-one'
7-
/*template: '<p>I am a template</p>'*/
2+
el: '#vue-app-one',
3+
data: {
4+
output: 'Your favourite food'
5+
},
6+
methods: {
7+
readRefs: function(){
8+
console.log(this.$refs);
9+
this.output = this.$refs.input.value;
10+
}
11+
}
812
});

index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
<script src="https://unpkg.com/vue"></script>
88
</head>
99
<body>
10-
<h1>Templates</h1>
11-
<div class="vue-app-one">
12-
<greeting></greeting>
13-
<greeting></greeting>
10+
<h1>Refs</h1>
11+
<div id="vue-app-one">
12+
<input type="text" ref="input" />
13+
<button v-on:click="readRefs">Submit</button>
14+
<p>{{ output }}</p>
1415
</div>
15-
<!--<div class="vue-app-one"></div>-->
16-
1716
</body>
1817

1918
<script src="app.js"></script>

0 commit comments

Comments
 (0)