Advertisement
Guest User

nice

a guest
Apr 24th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Vue Test Env</title>
  5.         <link rel="stylesheet" href="">
  6.         <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.6/vue.min.js"></script>
  7.     </head>
  8.     <body>
  9.       <div id="app">
  10.         <input type="text" v-model="name">
  11.         <button v-on:click="counter++">Increase</button>
  12.         <button v-on:click="counter--">Decrease</button>
  13.         <p>{{ name }}</p>
  14.         <p>Counter: {{ counter }}</p>
  15.         <p>Result: {{ result() }} </p>
  16.       </div>
  17.        
  18.             <script>
  19.                 new Vue({
  20.                     el: '#app',
  21.                     data: {
  22.                         name: 'Roy',
  23.                         counter: 0,
  24.                         secondCounter: 0
  25.                     },
  26.                     watch: {
  27.                         counter: function(value){
  28.                             var vm = this;
  29.                             setTimeout(function(){
  30.                                 vm.counter = 0;
  31.                             }, 2000);
  32.                         }
  33.                     },
  34.                     methods: {
  35.                         result: function() {
  36.                             return this.counter > 5 ? 'Greater than 5 ' : 'Smaller than 5'
  37.                         }
  38.                     }
  39.                 });
  40.         </script>
  41.     </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement