Created
February 9, 2019 10:45
-
-
Save revdfdev/617f10e74f251a76c4e6566802934a2e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yifasuk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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