Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Vue Test Env</title>
- <link rel="stylesheet" href="">
- <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.6/vue.min.js"></script>
- </head>
- <body>
- <div id="app">
- <input type="text" v-model="name">
- <button v-on:click="counter++">Increase</button>
- <button v-on:click="counter--">Decrease</button>
- <p>{{ name }}</p>
- <p>Counter: {{ counter }}</p>
- <p>Result: {{ result() }} </p>
- </div>
- <script>
- new Vue({
- el: '#app',
- data: {
- name: 'Roy',
- counter: 0,
- secondCounter: 0
- },
- watch: {
- counter: function(value){
- var vm = this;
- setTimeout(function(){
- vm.counter = 0;
- }, 2000);
- }
- },
- methods: {
- result: function() {
- return this.counter > 5 ? 'Greater than 5 ' : 'Smaller than 5'
- }
- }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement