s2e25 shorthands

This commit is contained in:
Tyrel Souza 2018-04-13 14:34:38 -04:00
parent d3bdeee2a3
commit 12053e4e2b
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 5 additions and 27 deletions

23
app.js
View File

@ -1,28 +1,11 @@
var app = new Vue({
el: '#app',
data: {
counter: 0,
secondCounter: 0,
link: 'https://tyrelsouza.com',
},
methods: {
result(){
console.log("result");
return this.counter >= 5 ? ">=5" : "<5"
}
},
watch: {
counter(value){
var vm = this;
setTimeout(function(){
vm.counter = 0;
}, 2000)
}
},
computed: {
output(){
console.log("computed");
return this.counter >= 5 ? ">=5" : "<5"
changeLink(){
this.link = "https://tyrel.bike";
}
}

View File

@ -6,14 +6,9 @@
</head>
<body>
<div id='app'>
<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>
<button @click="changeLink">Change to Link</button>
<a :href='link'>Link</a>
</div>
<script src="app.js" charset="utf-8"></script>
</body>
</html>