sergAccount

Untitled

Oct 1st, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.75 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Hello Vue</title>
  5.     <meta charset="utf-8">
  6.     <!-- https://unpkg.com/vue@2.6.11/dist/vue.min.js -->
  7.     <!-- подключение фреймворка vue.js -->
  8.     <script type="text/javascript" src="https://unpkg.com/vue"></script>
  9.     <style type="text/css">
  10.     .active {
  11.       color: red
  12.     }
  13.     .some {
  14.       font-size: 24px;
  15.     }    
  16.     </style>
  17. </head>
  18. <body>
  19. <!-- элемент div c идентификатором app -->
  20. <!-- v-for -->
  21. <div id="app">       
  22.  
  23.     <input type="button" value="INCREMENT COUNTER1" @click="incCounter()">  
  24.  
  25.     <button-counter ref="counter3"></button-counter>
  26.     <button-counter ref="counter4"></button-counter>
  27. </div>
  28. </body>
  29.  
  30. <template id="counter_tid">  
  31.   <button @click="inc">{{count}}</button>    
  32. </template>
  33.  
  34. <script type="text/javascript">
  35.   //
  36.   Vue.component('button-counter', {
  37.     template: '#counter_tid',
  38.     data: function () {
  39.       return {
  40.         count: 0
  41.       }
  42.     },    
  43.     methods: {
  44.        inc: function() {
  45.              console.log('inc!!!!');
  46.              this.count++;
  47.        }      
  48.     }
  49.   });
  50.  
  51.     // создаем объект Vue (экземпляр Vue)
  52.     new Vue({
  53.   el: "#app",
  54.   data: {    
  55.     showFlag: false,
  56.     result: '',
  57.     price: 10.0777,
  58.     bonus2: 2,
  59.     message: 'some message',                        
  60.     products: [
  61.       {name: "Product1", price: 100},
  62.       {name: "Product2", price: 200}
  63.     ]
  64.   },
  65.   methods : {
  66.       incCounter: function(todo){
  67.             alert('incCounter');            
  68.             this.$refs.counter3.inc();
  69.       }
  70.   },
  71.   mounted: function() {
  72.       console.info('mounted fired');
  73.       // обращаемся к узлу DOM
  74.   }
  75. })
  76. </script>
  77. </html>
Add Comment
Please, Sign In to add comment