Advertisement
loloof64

Udemy Vue JS Couse - Assignemnt 3 - JS

Oct 1st, 2020
1,758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const app = Vue.createApp({
  2.     data() {
  3.         return {
  4.             result: 0,
  5.         }
  6.     },
  7.     methods: {
  8.         addOne() {
  9.             this.result += 1;
  10.         },
  11.         addFive() {
  12.             this.result += 5;
  13.         }
  14.     },
  15.     computed: {
  16.         shownResult() {
  17.             const limit = 37;
  18.             if (this.result < limit) {
  19.                 return 'Not there yet.'
  20.             }
  21.             if (this.result > limit) {
  22.                 return 'Too much!'
  23.             }
  24.             return this.result;
  25.         }
  26.     },
  27.     watch: {
  28.         shownResult() {
  29.             setTimeout(() => {
  30.                 this.result = 0;
  31.             }, 5000);
  32.         }
  33.     }
  34. });
  35.  
  36. app.mount('#assignment');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement