Skip to content

Instantly share code, notes, and snippets.

@revdfdev
Created February 9, 2019 10:45
Show Gist options
  • Select an option

  • Save revdfdev/617f10e74f251a76c4e6566802934a2e to your computer and use it in GitHub Desktop.

Select an option

Save revdfdev/617f10e74f251a76c4e6566802934a2e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yifasuk
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<div id="app">
<button v-on:click="counter++">Increase</button>
<button v-on:click="counter--">Decrease</button>
<button v-on:click="secondCounter++">Increase Second</button>
<p>{{counter}} | {{secondCounter}}</p>
<p>{{result()}} | {{output}} </p>
</div>
<script id="jsbin-javascript">
new Vue({
el: "#app",
data: {
counter: 0,
secondCounter: 0,
result: ""
},
computed: {
output: function() {
console.log("Computed");
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
},
watch: {
counter: function(value) {
var vm = this;
setTimeout(function(){
vm.counter = 0;
}, 3000)
}
},
methods: {
result: function() {
console.log("Resulted")
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
}
})
</script>
<script id="jsbin-source-javascript" type="text/javascript">new Vue({
el: "#app",
data: {
counter: 0,
secondCounter: 0,
result: ""
},
computed: {
output: function() {
console.log("Computed");
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
},
watch: {
counter: function(value) {
var vm = this;
setTimeout(function(){
vm.counter = 0;
}, 3000)
}
},
methods: {
result: function() {
console.log("Resulted")
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
}
})</script></body>
</html>
new Vue({
el: "#app",
data: {
counter: 0,
secondCounter: 0,
result: ""
},
computed: {
output: function() {
console.log("Computed");
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
},
watch: {
counter: function(value) {
var vm = this;
setTimeout(function(){
vm.counter = 0;
}, 3000)
}
},
methods: {
result: function() {
console.log("Resulted")
return this.counter > 5 ? "Greater than 5" : "Less than 5"
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment