Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <title>Learn Vue JS</title>
  7.     <meta name="viewport" content="width=device-width, initial-scale=1">
  8.     <style>
  9.         .is-loading { background-color: red; }
  10.     </style>
  11. </head>
  12. <body>
  13.     <div id="root">
  14.         <!-- <input type="text" id="input" v-model="message" />
  15.         <p>The value of input is {{message}}</p> -->
  16.  
  17.         <ul>
  18.             <li v-for="name in names" v-text="name"></li>
  19.         </ul>
  20.  
  21.         <input type="text" v-model="newName">
  22.         <button @click="addName">Add name</button>
  23.  
  24.         <hr />
  25.  
  26.         <button :title="title" :class="{ 'is-loading': isLoading }" @click="toggleClass">Hover me</button>
  27.         <button :disabled="disabled" @click="disableMe">Disable me</button>
  28.  
  29.         <hr />
  30.  
  31.         {{ reversedMessage }}
  32.  
  33.         <hr />
  34.  
  35.         <h1>All Tasks</h1>
  36.         <ul>
  37.             <li v-for="task in tasks" v-text="task.description"></li>
  38.         </ul>
  39.  
  40.  
  41.         <hr />
  42.  
  43.         <h1>Incomplete Tasks</h1>
  44.         <ul>
  45.             <li v-for="task in incompleteTasks">
  46.                 <input type="checkbox" v-model="task.completed"> {{ task.description }}
  47.             </li>
  48.         </ul>
  49.  
  50.         <h1>Completed Tasks</h1>
  51.         <ul>
  52.             <li v-for="task in completedTasks">
  53.                 <input type="checkbox" v-model="task.completed"> {{ task.description }}
  54.             </li>
  55.         </ul>
  56.  
  57.         <hr />
  58.         <h1>Components</h1>
  59.        
  60.         <task>Go to the store</task>
  61.         <task>Go to the store</task>
  62.         <task>Go to work</task>
  63.  
  64.     </div>
  65.  
  66.     <script src="https://unpkg.com/vue@2.6.9/dist/vue.js"></script>
  67.     <script src="main.js"></script>
  68.     <script>
  69.         var app = new Vue({
  70.             el: '#root',
  71.             data: {
  72.                 message: 'Hello world',
  73.                 newName: '',
  74.                 names: ['Joe', 'John', 'Jane'],
  75.                 title: "Setting the title",
  76.                 isLoading: false,
  77.                 disabled: false,
  78.                 tasks: [
  79.                     { description: "Go To Store", completed: true },
  80.                     { description: "Finish screencast", completed: false },
  81.                     { description: "Make donation", completed: false },
  82.                     { description: "Clear inbox", completed: false },
  83.                     { description: "Clear inbox", completed: false },
  84.                     { description: "Clean room", completed: true }
  85.                 ]
  86.             },
  87.  
  88.             methods: {
  89.                 addName() {
  90.                     this.names.push(this.newName);
  91.                     this.newName = '';
  92.                 },
  93.  
  94.                 toggleClass() {
  95.                     this.isLoading = !this.isLoading
  96.                 },
  97.  
  98.                 disableMe() {
  99.                     this.disabled = true;
  100.                 }
  101.             },
  102.  
  103.             computed: {
  104.                 reversedMessage() {
  105.                     return this.message.split('').reverse().join('');
  106.                 },
  107.  
  108.                 incompleteTasks() {
  109.                     return this.tasks.filter(task => !task.completed);
  110.                 },
  111.  
  112.                 completedTasks() {
  113.                     return this.tasks.filter(task => task.completed);
  114.                 }
  115.  
  116.             }
  117.         });
  118.     </script>
  119. </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement