s2e23 computed properties

This commit is contained in:
Tyrel Souza 2018-04-13 14:27:33 -04:00
parent be0ddd00f0
commit 8ac77e11d5
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 21 additions and 3 deletions

17
app.js
View File

@ -1,6 +1,21 @@
var app = new Vue({
el: '#app',
data: {
name: "Tyrel"
counter: 0,
secondCounter: 0,
},
methods: {
result(){
console.log("result");
return this.counter >= 5 ? ">=5" : "<5"
}
},
computed: {
output(){
console.log("computed");
return this.counter >= 5 ? ">=5" : "<5"
}
}
})

View File

@ -6,8 +6,11 @@
</head>
<body>
<div id='app'>
<input type="text" v-model="name">
<p>{{name}}</p>
<button v-on:click="counter++">Increase</button>
<button v-on:click="counter--">Decrease</button>
<button v-on:click="secondCounter++">Increase 2nd Counter</button>
<p>counter: {{counter}} | {{secondCounter}}</p>
<p>result: {{result()}} | {{ output }}</p>
</div>
<script src="app.js" charset="utf-8"></script>